PHP Trait gossi\codegen\model\parts\TraitsPart

For all models that can have traits
Author: Thomas Gossmann
Afficher le fichier Open project: gossi/php-code-generator

Méthodes publiques

Méthode Description
addTrait ( PhpTrait | string $trait ) Adds a trait.
addUseStatement ( string $qualifiedName, null | string $alias = null ) Adds a use statement with an optional alias
getNamespace ( ) : string Returns the namespace
getTraits ( ) : string[] Returns a collection of traits
hasTrait ( PhpTrait | string $trait ) : boolean Checks whether a trait exists
removeTrait ( PhpTrait | string $trait ) Removes a trait.
removeUseStatement ( string $qualifiedName ) Removes a use statement
setTraits ( array $traits ) Sets a collection of traits

Method Details

addTrait() public méthode

If the trait is passed as PhpTrait object, the trait is also added as use statement.
public addTrait ( PhpTrait | string $trait )
$trait gossi\codegen\model\PhpTrait | string trait or qualified name

addUseStatement() abstract public méthode

Adds a use statement with an optional alias
abstract public addUseStatement ( string $qualifiedName, null | string $alias = null )
$qualifiedName string
$alias null | string

getNamespace() abstract public méthode

Returns the namespace
abstract public getNamespace ( ) : string
Résultat string

getTraits() public méthode

Returns a collection of traits
public getTraits ( ) : string[]
Résultat string[]

hasTrait() public méthode

Checks whether a trait exists
public hasTrait ( PhpTrait | string $trait ) : boolean
$trait gossi\codegen\model\PhpTrait | string
Résultat boolean `true` if it exists and `false` if not

removeTrait() public méthode

If the trait is passed as PhpTrait object, the trait is also removed from use statements.
public removeTrait ( PhpTrait | string $trait )
$trait gossi\codegen\model\PhpTrait | string trait or qualified name

removeUseStatement() abstract public méthode

Removes a use statement
abstract public removeUseStatement ( string $qualifiedName )
$qualifiedName string

setTraits() public méthode

Sets a collection of traits
public setTraits ( array $traits )
$traits array