1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-27 12:24:39 +01:00
PHP-Parser/lib/PHPParser/BuilderFactory.php
2012-03-10 23:25:26 +01:00

34 lines
901 B
PHP

<?php
/**
* @method PHPParser_Builder_Class class(string $name) Creates a class builder.
*/
class PHPParser_BuilderFactory
{
/*
* "class" is a reserved keyword, so we implement the method as _class()
* and redirect class() to it through __call magic
*/
protected function _class($name) {
return new PHPParser_Builder_Class($name);
}
/**
* Creates a method builder.
*
* @param string $name Name of the method
*
* @return PHPParser_Builder_Method The created method class builder
*/
public function method($name) {
return new PHPParser_Builder_Method($name);
}
public function __call($name, array $args) {
if ('class' === $name) {
return call_user_func_array(array($this, '_class'), $args);
}
throw new LogicException(sprintf('Method "%s" does not exist', $name));
}
}