interface TraitsInterface

Represents models that can have traits

Methods

$this
addTrait(PhpTrait|string $trait)

Adds a trait.

string[]
getTraits()

Returns a collection of traits

bool
hasTrait(PhpTrait|string $trait)

Checks whether a trait exists

$this
removeTrait(PhpTrait|string $trait)

Removes a trait.

$this
setTraits(array $traits)

Sets a collection of traits

Details

at line line 20
$this addTrait(PhpTrait|string $trait)

Adds a trait.

If the trait is passed as PhpTrait object, the trait is also added as use statement.

Parameters

PhpTrait|string $trait trait or qualified name

Return Value

$this

at line line 27
string[] getTraits()

Returns a collection of traits

Return Value

string[]

at line line 35
bool hasTrait(PhpTrait|string $trait)

Checks whether a trait exists

Parameters

PhpTrait|string $trait

Return Value

bool true if it exists and false if not

at line line 46
$this removeTrait(PhpTrait|string $trait)

Removes a trait.

If the trait is passed as PhpTrait object, the trait is also removed from use statements.

Parameters

PhpTrait|string $trait trait or qualified name

Return Value

$this

at line line 54
$this setTraits(array $traits)

Sets a collection of traits

Parameters

array $traits

Return Value

$this