| Total Complexity | 8 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class PhpInterface extends OOPStructure |
||
| 10 | { |
||
| 11 | protected array $extends = []; |
||
| 12 | protected ?Comment $docBlock = null; |
||
| 13 | |||
| 14 | 4 | public function generate(): string |
|
| 15 | { |
||
| 16 | // Extends |
||
| 17 | 4 | $extends = ''; |
|
| 18 | 4 | if (!empty($this->extends)) { |
|
| 19 | 3 | $extends = ' extends '.join(', ', $this->extends); |
|
| 20 | } |
||
| 21 | |||
| 22 | return <<<CODE |
||
| 23 | 4 | {$this->buildDocBlock()}interface $this->name{$extends} |
|
| 24 | { |
||
| 25 | 4 | {$this->generateContent()} |
|
| 26 | } |
||
| 27 | CODE; |
||
| 28 | } |
||
| 29 | |||
| 30 | 1 | public function createSignature(string $name, string $returnType = ''): Signature |
|
| 31 | { |
||
| 32 | 1 | $signature = new Signature($name, Modifier::PUBLIC, $returnType); |
|
| 33 | 1 | $this->append($signature); |
|
| 34 | |||
| 35 | 1 | return $signature; |
|
| 36 | } |
||
| 37 | |||
| 38 | 1 | public function addSignature(string $name, string $returnType = ''): self |
|
| 39 | { |
||
| 40 | 1 | return $this->append(new Signature($name, Modifier::PUBLIC, $returnType)); |
|
| 41 | } |
||
| 42 | |||
| 43 | 1 | public function addSignatureFromMethod(Method $method) |
|
| 44 | { |
||
| 45 | 1 | return $this->append($method->signature); |
|
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param mixed $value |
||
| 50 | */ |
||
| 51 | 1 | public function addConst(string $name, $value): self |
|
| 52 | { |
||
| 53 | 1 | return $this->append(Property::new($name, Modifier::PUBLIC, '', $value)->setConst()); |
|
| 54 | } |
||
| 55 | |||
| 56 | 1 | public function addExtends(string ...$extends) |
|
| 63 | } |
||
| 64 | } |
||
| 65 |