<?php
namespace PhpParser\Builder;
use PhpParser\BuilderAbstract;
use PhpParser\Node;
use PhpParser\Node\Stmt;
class Use_ extends BuilderAbstract {
protected $name;
protected $type;
protected $alias = null;
public function __construct($name, $type) {
$this->name = $this->normalizeName($name);
$this->type = $type;
}
protected function as_($alias) {
$this->alias = $alias;
return $this;
}
public function __call($name, $args) {
if (method_exists($this, $name . '_')) {
return call_user_func_array(array($this, $name . '_'), $args);
}
throw new \LogicException(sprintf('Method "%s" does not exist', $name));
}
public function getNode() {
$alias = null !== $this->alias ? $this->alias : $this->name->getLast();
return new Stmt\Use_(array(
new Stmt\UseUse($this->name, $alias)
), $this->type);
}
}