TraitsPart
Traits part.
For all models that can have traits
Tags
Table of Contents
- $traits : Set
- addTrait() : $this
- Adds a trait.
- getTraits() : Set
- Returns a collection of traits.
- hasTrait() : bool
- Checks whether a trait exists.
- hasTraitByName() : bool
- Checks whether a trait exists.
- removeTrait() : $this
- Removes a trait.
- removeTraitByName() : $this
- Removes a trait.
- setTraits() : $this
- Sets a collection of traits.
- initTraits() : void
Properties
$traits
private
Set
$traits
Methods
addTrait()
Adds a trait.
public
addTrait(PhpTrait $trait) : $this
If the trait is passed as PhpTrait object, the trait is also added as use statement.
Parameters
- $trait : PhpTrait
-
trait or qualified name
Return values
$this —getTraits()
Returns a collection of traits.
public
getTraits() : Set
Return values
Set —hasTrait()
Checks whether a trait exists.
public
hasTrait(PhpTrait $trait) : bool
Parameters
- $trait : PhpTrait
Return values
bool —true
if it exists and false
if not
hasTraitByName()
Checks whether a trait exists.
public
hasTraitByName(string $name) : bool
Parameters
- $name : string
Tags
Return values
bool —true
if it exists and false
if not
removeTrait()
Removes a trait.
public
removeTrait(PhpTrait $trait) : $this
If the trait is passed as PhpTrait object, the trait is also removed from use statements.
Parameters
- $trait : PhpTrait
-
trait or qualified name
Return values
$this —removeTraitByName()
Removes a trait.
public
removeTraitByName(string $traitName) : $this
If the trait is passed as PhpTrait object, the trait is also removed from use statements.
Parameters
- $traitName : string
-
trait qualified name
Tags
Return values
$this —setTraits()
Sets a collection of traits.
public
setTraits(array<string|int, mixed> $traits) : $this
Parameters
- $traits : array<string|int, mixed>
Tags
Return values
$this —initTraits()
private
initTraits() : void