TraitsInterface
Represents models that can have traits.
Tags
Table of Contents
- 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.
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
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 $traitName) : bool
Parameters
- $traitName : string
-
The name of the trait
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
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
Return values
$this —setTraits()
Sets a collection of traits.
public
setTraits(array<string|int, PhpTrait> $traits) : $this
Parameters
- $traits : array<string|int, PhpTrait>