Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
21 / 21
100.00% covered (success)
100.00%
11 / 11
CRAP
100.00% covered (success)
100.00%
1 / 1
Service
100.00% covered (success)
100.00%
21 / 21
100.00% covered (success)
100.00%
11 / 11
13
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getContextualPart
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDocSubPackages
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getMethods
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 addMethod
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getMethod
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getExtends
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 getReservedMethodsInstance
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setMethodsFromSerializedJson
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 setMethods
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 toJsonSerialize
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace WsdlToPhp\PackageGenerator\Model;
6
7use WsdlToPhp\PackageGenerator\ConfigurationReader\ServiceReservedMethod;
8use WsdlToPhp\PackageGenerator\Container\Model\Method as MethodContainer;
9use WsdlToPhp\PackageGenerator\Generator\Generator;
10use WsdlToPhp\PackageGenerator\Generator\Utils;
11
12/**
13 * Class Service stands for an available service containing the methods/operations described in the WSDL.
14 */
15class Service extends AbstractModel
16{
17    public const DEFAULT_SERVICE_CLASS_NAME = 'Service';
18
19    protected MethodContainer $methods;
20
21    public function __construct(Generator $generator, string $name)
22    {
23        parent::__construct($generator, $name);
24        $this->setMethods(new MethodContainer($generator));
25    }
26
27    public function getContextualPart(): string
28    {
29        return $this->getGenerator()->getOptionServicesFolder();
30    }
31
32    public function getDocSubPackages(): array
33    {
34        return [
35            'Services',
36        ];
37    }
38
39    public function getMethods(): MethodContainer
40    {
41        return $this->methods;
42    }
43
44    public function addMethod(string $methodName, $methodParameterType, $methodReturnType, $methodIsUnique = true): Method
45    {
46        $method = new Method($this->getGenerator(), $methodName, $methodParameterType, $methodReturnType, $this, $methodIsUnique);
47        $this->methods->add($method);
48
49        return $method;
50    }
51
52    public function getMethod(string $methodName): ?Method
53    {
54        return $this->methods->getMethodByName($methodName);
55    }
56
57    public function getExtends(bool $short = false): string
58    {
59        $extends = $this->getGenerator()->getOptionSoapClientClass();
60
61        return $short ? Utils::removeNamespace($extends) : $extends;
62    }
63
64    public function getReservedMethodsInstance(?string $filename = null): ServiceReservedMethod
65    {
66        return ServiceReservedMethod::instance($filename);
67    }
68
69    public function setMethodsFromSerializedJson(array $methods): void
70    {
71        foreach ($methods as $method) {
72            $this->methods->add(self::instanceFromSerializedJson($this->generator, $method)->setOwner($this));
73        }
74    }
75
76    protected function setMethods(MethodContainer $methodContainer): self
77    {
78        $this->methods = $methodContainer;
79
80        return $this;
81    }
82
83    protected function toJsonSerialize(): array
84    {
85        return [
86            'methods' => $this->methods,
87        ];
88    }
89}