1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace WsdlToPhp\PhpGenerator\Component; |
6
|
|
|
|
7
|
|
|
use WsdlToPhp\PhpGenerator\Element\PhpClass as PhpClassElement; |
8
|
|
|
use WsdlToPhp\PhpGenerator\Element\PhpMethod as PhpMethodElement; |
9
|
|
|
use WsdlToPhp\PhpGenerator\Element\PhpProperty as PhpPropertyElement; |
10
|
|
|
|
11
|
|
|
class PhpClass extends AbstractComponent |
12
|
|
|
{ |
13
|
12 |
|
public function __construct(string $name, bool $abstract = false, ?string $extends = null, array $interfaces = []) |
14
|
|
|
{ |
15
|
12 |
|
$this->setMainElement(new PhpClassElement($name, $abstract, $extends, $interfaces)); |
16
|
12 |
|
} |
17
|
|
|
|
18
|
16 |
|
public function addMethodElement(PhpMethodElement $method): self |
19
|
|
|
{ |
20
|
16 |
|
$this->mainElement->addChild($method); |
21
|
|
|
|
22
|
16 |
|
return $this; |
23
|
|
|
} |
24
|
|
|
|
25
|
10 |
|
public function addMethod(string $name, array $parameters = [], ?string $returnType = null, string $access = PhpMethodElement::ACCESS_PUBLIC, bool $abstract = false, bool $static = false, bool $final = false, bool $hasBody = true): self |
26
|
|
|
{ |
27
|
10 |
|
return $this->addMethodElement(new PhpMethodElement($name, $parameters, $returnType, $access, $abstract, $static, $final, $hasBody)); |
28
|
|
|
} |
29
|
|
|
|
30
|
10 |
|
public function addPropertyElement(PhpPropertyElement $property): self |
31
|
|
|
{ |
32
|
10 |
|
$this->mainElement->addChild($property); |
33
|
|
|
|
34
|
10 |
|
return $this; |
35
|
|
|
} |
36
|
|
|
|
37
|
10 |
|
public function addProperty(string $name, $value = null, string $access = PhpPropertyElement::ACCESS_PUBLIC, $type = null): self |
38
|
|
|
{ |
39
|
10 |
|
return $this->addPropertyElement(new PhpPropertyElement($name, $value, $access, $type)); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|