Total Complexity | 14 |
Total Lines | 87 |
Duplicated Lines | 0 % |
Coverage | 97.3% |
Changes | 0 |
1 | <?php |
||
14 | class PhpFile extends AbstractComponent |
||
15 | { |
||
16 | 12 | public function __construct(string $name) |
|
19 | 12 | } |
|
20 | |||
21 | /** |
||
22 | * @return PhpFileElement[] |
||
23 | */ |
||
24 | 10 | public function getElements(): array |
|
25 | { |
||
26 | return [ |
||
|
|||
27 | 10 | $this->getMainElement(), |
|
28 | ]; |
||
29 | } |
||
30 | |||
31 | 4 | public function addClassComponent(PhpClassComponent $class): self |
|
32 | { |
||
33 | 4 | $this->mainElement->addChild($class->toString()); |
|
34 | |||
35 | 4 | return $this; |
|
36 | } |
||
37 | |||
38 | 2 | public function addInterfaceComponent(PhpInterfaceComponent $interface): self |
|
43 | } |
||
44 | |||
45 | 2 | public function addVariableElement(PhpVariableElement $variable): self |
|
46 | { |
||
47 | 2 | $this->mainElement->addChild($variable); |
|
48 | |||
49 | 2 | return $this; |
|
50 | } |
||
51 | |||
52 | 2 | public function addVariable(string $name, $value = null): self |
|
53 | { |
||
54 | 2 | return $this->addVariableElement(new PhpVariableElement($name, $value)); |
|
55 | } |
||
56 | |||
57 | 2 | public function addFunctionElement(PhpFunctionElement $function): self |
|
58 | { |
||
59 | 2 | $this->mainElement->addChild($function); |
|
60 | |||
61 | 2 | return $this; |
|
62 | } |
||
63 | |||
64 | 2 | public function addFunction(string $name, array $parameters = []): self |
|
67 | } |
||
68 | |||
69 | 6 | public function addUse(string $use, string $as = null, bool $last = false): self |
|
70 | { |
||
71 | 6 | $expression = empty($as) ? "use %1\$s;%3\$s" : "use %1\$s as %2\$s;%3\$s"; |
|
72 | 6 | $this->mainElement->addChild(sprintf($expression, $use, $as, $last ? self::BREAK_LINE_CHAR : '')); |
|
73 | |||
74 | 6 | return $this; |
|
75 | } |
||
76 | |||
77 | 6 | public function setDeclareElement(PhpDeclare $phpDeclare): self |
|
82 | } |
||
83 | |||
84 | 2 | public function setDeclare(string $name, $value): self |
|
87 | } |
||
88 | |||
89 | 6 | public function setNamespace(string $namespace): self |
|
90 | { |
||
91 | 6 | $this->mainElement->addChild( |
|
92 | sprintf( |
||
103 |