|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace WsdlToPhp\PackageGenerator\Container\Model; |
|
6
|
|
|
|
|
7
|
|
|
use WsdlToPhp\PackageGenerator\Model\Method as MethodModel; |
|
8
|
|
|
use WsdlToPhp\PackageGenerator\Model\Service as Model; |
|
9
|
|
|
|
|
10
|
|
|
final class Service extends AbstractModel |
|
11
|
|
|
{ |
|
12
|
124 |
|
public function addService(string $serviceName, string $methodName, $methodParameter, $methodReturn): Service |
|
13
|
|
|
{ |
|
14
|
124 |
|
if (!$this->get($serviceName) instanceof Model) { |
|
15
|
122 |
|
$this->add(new Model($this->generator, $serviceName)); |
|
16
|
|
|
} |
|
17
|
124 |
|
$serviceMethod = $this->get($serviceName)->getMethod($methodName); |
|
18
|
|
|
|
|
19
|
|
|
// Service method does not already exist, register it |
|
20
|
124 |
|
if (!$serviceMethod instanceof MethodModel) { |
|
21
|
124 |
|
$this->get($serviceName)->addMethod($methodName, $methodParameter, $methodReturn); |
|
22
|
|
|
} |
|
23
|
|
|
// Service method exists with a different signature, register it too by identifying the service functions as non unique functions |
|
24
|
26 |
|
elseif ($methodParameter !== $serviceMethod->getParameterType()) { |
|
25
|
2 |
|
$serviceMethod->setUnique(false); |
|
26
|
2 |
|
$this->get($serviceName)->addMethod($methodName, $methodParameter, $methodReturn, false); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
124 |
|
return $this; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
78 |
|
public function getServiceByName(string $name): ?Model |
|
33
|
|
|
{ |
|
34
|
78 |
|
return $this->get($name); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
4 |
|
public function getMethods(): Method |
|
38
|
|
|
{ |
|
39
|
4 |
|
$methods = new Method($this->generator); |
|
40
|
|
|
|
|
41
|
|
|
/** @var Model $service */ |
|
42
|
4 |
|
foreach ($this->objects as $service) { |
|
43
|
4 |
|
foreach ($service->getMethods() as $method) { |
|
44
|
4 |
|
$methods->add($method); |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
4 |
|
return $methods; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
340 |
|
protected function objectClass(): string |
|
52
|
|
|
{ |
|
53
|
340 |
|
return Model::class; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|