3 namespace PhpParser\Builder;
7 use PhpParser\Node\Stmt;
9 class Namespace_ extends PhpParser\BuilderAbstract
12 private $stmts = array();
15 * Creates a namespace builder.
17 * @param Node\Name|string|null $name Name of the namespace
19 public function __construct($name) {
20 $this->name = null !== $name ? $this->normalizeName($name) : null;
26 * @param Node|PhpParser\Builder $stmt The statement to add
28 * @return $this The builder instance (for fluid interface)
30 public function addStmt($stmt) {
31 $this->stmts[] = $this->normalizeNode($stmt);
37 * Adds multiple statements.
39 * @param array $stmts The statements to add
41 * @return $this The builder instance (for fluid interface)
43 public function addStmts(array $stmts) {
44 foreach ($stmts as $stmt) {
45 $this->addStmt($stmt);
52 * Returns the built node.
54 * @return Node The built node
56 public function getNode() {
57 return new Stmt\Namespace_($this->name, $this->stmts);