PHP Class Pop\Code\Generator\ClassGenerator

Author: Nick Sagona, III ([email protected])
Inheritance: implements Pop\Code\Generator\GeneratorInterface
Show file Open project: nicksagona/PopPHP Class Usage Examples

Protected Properties

Property Type Description
$abstract boolean Class abstract flag
$docblock DocblockGenerator Docblock generator object
$indent string Class indent
$interface string Interface that is implemented
$methods array Array of method generator objects
$name string Class name
$namespace NamespaceGenerator Namespace generator object
$output string Class output
$parent string Parent class that is extended
$properties array Array of property generator objects

Public Methods

Method Description
__construct ( string $name, string $parent = null, string $interface = null, boolean $abstract = false ) : ClassGenerator Constructor
__toString ( ) : string Print method
addMethod ( MethodGenerator $method ) : ClassGenerator Add a class method
addProperty ( PropertyGenerator $property ) : ClassGenerator Add a class property
factory ( string $name, string $parent = null, string $interface = null, boolean $abstract = false ) : ClassGenerator Static method to instantiate the class generator object and return itself to facilitate chaining methods together.
getDocblock ( ) : DocblockGenerator Access the docblock generator object
getIndent ( ) : string Get the class indent
getInterface ( ) : string Get the class interface
getMethod ( mixed $method ) : MethodGenerator Get a method property
getMethods ( ) : array Get all methods
getName ( ) : string Get the class name
getNamespace ( ) : NamespaceGenerator Access the namespace generator object
getParent ( ) : string Get the class parent
getProperties ( ) : array Get all properties
getProperty ( mixed $property ) : PropertyGenerator Get a class property
isAbstract ( ) : boolean Get the class abstract flag
removeMethod ( mixed $method ) : ClassGenerator Remove a method property
removeProperty ( mixed $property ) : ClassGenerator Remove a class property
render ( boolean $ret = false ) : mixed Render method
setAbstract ( boolean $abstract = false ) : ClassGenerator Set the class abstract flag
setDocblock ( DocblockGenerator $docblock ) : ClassGenerator Set the docblock generator object
setIndent ( string $indent = null ) : ClassGenerator Set the class indent
setInterface ( string $interface = null ) : ClassGenerator Set the class interface
setName ( string $name ) : ClassGenerator Set the class name
setNamespace ( NamespaceGenerator $namespace ) : ClassGenerator Set the namespace generator object
setParent ( string $parent = null ) : ClassGenerator Set the class parent

Protected Methods

Method Description
formatMethods ( ) : string Method to format the methods
formatProperties ( ) : string Method to format the properties

Method Details

__construct() public method

Instantiate the class generator object
public __construct ( string $name, string $parent = null, string $interface = null, boolean $abstract = false ) : ClassGenerator
$name string
$parent string
$interface string
$abstract boolean
return ClassGenerator

__toString() public method

Print method
public __toString ( ) : string
return string

addMethod() public method

Add a class method
public addMethod ( MethodGenerator $method ) : ClassGenerator
$method MethodGenerator
return ClassGenerator

addProperty() public method

Add a class property
public addProperty ( PropertyGenerator $property ) : ClassGenerator
$property PropertyGenerator
return ClassGenerator

factory() public static method

Static method to instantiate the class generator object and return itself to facilitate chaining methods together.
public static factory ( string $name, string $parent = null, string $interface = null, boolean $abstract = false ) : ClassGenerator
$name string
$parent string
$interface string
$abstract boolean
return ClassGenerator

formatMethods() protected method

Method to format the methods
protected formatMethods ( ) : string
return string

formatProperties() protected method

Method to format the properties
protected formatProperties ( ) : string
return string

getDocblock() public method

Access the docblock generator object
public getDocblock ( ) : DocblockGenerator
return DocblockGenerator

getIndent() public method

Get the class indent
public getIndent ( ) : string
return string

getInterface() public method

Get the class interface
public getInterface ( ) : string
return string

getMethod() public method

Get a method property
public getMethod ( mixed $method ) : MethodGenerator
$method mixed
return MethodGenerator

getMethods() public method

Get all methods
public getMethods ( ) : array
return array

getName() public method

Get the class name
public getName ( ) : string
return string

getNamespace() public method

Access the namespace generator object
public getNamespace ( ) : NamespaceGenerator
return NamespaceGenerator

getParent() public method

Get the class parent
public getParent ( ) : string
return string

getProperties() public method

Get all properties
public getProperties ( ) : array
return array

getProperty() public method

Get a class property
public getProperty ( mixed $property ) : PropertyGenerator
$property mixed
return PropertyGenerator

isAbstract() public method

Get the class abstract flag
public isAbstract ( ) : boolean
return boolean

removeMethod() public method

Remove a method property
public removeMethod ( mixed $method ) : ClassGenerator
$method mixed
return ClassGenerator

removeProperty() public method

Remove a class property
public removeProperty ( mixed $property ) : ClassGenerator
$property mixed
return ClassGenerator

render() public method

Render method
public render ( boolean $ret = false ) : mixed
$ret boolean
return mixed

setAbstract() public method

Set the class abstract flag
public setAbstract ( boolean $abstract = false ) : ClassGenerator
$abstract boolean
return ClassGenerator

setDocblock() public method

Set the docblock generator object
public setDocblock ( DocblockGenerator $docblock ) : ClassGenerator
$docblock DocblockGenerator
return ClassGenerator

setIndent() public method

Set the class indent
public setIndent ( string $indent = null ) : ClassGenerator
$indent string
return ClassGenerator

setInterface() public method

Set the class interface
public setInterface ( string $interface = null ) : ClassGenerator
$interface string
return ClassGenerator

setName() public method

Set the class name
public setName ( string $name ) : ClassGenerator
$name string
return ClassGenerator

setNamespace() public method

Set the namespace generator object
public setNamespace ( NamespaceGenerator $namespace ) : ClassGenerator
$namespace NamespaceGenerator
return ClassGenerator

setParent() public method

Set the class parent
public setParent ( string $parent = null ) : ClassGenerator
$parent string
return ClassGenerator

Property Details

$abstract protected property

Class abstract flag
protected bool $abstract
return boolean

$docblock protected property

Docblock generator object
protected DocblockGenerator,Pop\Code\Generator $docblock
return DocblockGenerator

$indent protected property

Class indent
protected string $indent
return string

$interface protected property

Interface that is implemented
protected string $interface
return string

$methods protected property

Array of method generator objects
protected array $methods
return array

$name protected property

Class name
protected string $name
return string

$namespace protected property

Namespace generator object
protected NamespaceGenerator,Pop\Code\Generator $namespace
return NamespaceGenerator

$output protected property

Class output
protected string $output
return string

$parent protected property

Parent class that is extended
protected string $parent
return string

$properties protected property

Array of property generator objects
protected array $properties
return array