Skip to content

Latest commit

 

History

History
44 lines (38 loc) · 632 Bytes

Nameable.md

File metadata and controls

44 lines (38 loc) · 632 Bytes

Nameable ⇒ GettableName ⇒ DefaultableName

trait DefaultableName
/**
 * @param string|null $name
 * @return string
 */
public function defaultName(?string $name = null): string
{
    return $name ?? DEFAULT_NAME; // 'default_name'
}
trait GettableName
use DefaultableName;

/** @var string */
protected $name;

/**
 * @return string
 */
public function getName(): string
{
    return $this->name;
    }
trait Nameable
use GettableName;

/**
 * @param string $name
 * @return self
 */
public function setName(string $name): self
{
    $this->name = $name;
    return $this;
}