PHP Trait gossi\codegen\model\parts\TraitsPart

For all models that can have traits
Author: Thomas Gossmann
Datei anzeigen Open project: gossi/php-code-generator

Public Methods

Method 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 method

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 method

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 method

Returns the namespace
abstract public getNamespace ( ) : string
return string

getTraits() public method

Returns a collection of traits
public getTraits ( ) : string[]
return string[]

hasTrait() public method

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

removeTrait() public method

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 method

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

setTraits() public method

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