Issues (2551)

src/Impl/Webservice/WSService.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Jabe\Impl\Webservice;
4
5
use Jabe\Impl\Bpmn\Webservice\BpmnInterfaceImplementationInterface;
6
use Jabe\Impl\Cfg\ProcessEngineConfigurationImpl;
7
use Jabe\Impl\Util\ReflectUtil;
8
9
class WSService implements BpmnInterfaceImplementationInterface
10
{
11
    protected $name;
12
13
    protected $location;
14
15
    protected $operations = [];
16
17
    protected $wsdlLocation;
18
19
    protected $client;
20
21
    public function __construct(string $name, string $location, $data)
22
    {
23
        $this->name = $name;
24
        $this->location = $location;
25
        $this->operations = [];
26
        if ($data instanceof SyncWebServiceClientInterface) {
27
            $this->client = $data;
28
        } elseif (is_string($data)) {
29
            $this->wsdlLocation = $data;
30
        }
31
    }
32
33
    public function addOperation(WSOperation $operation): void
34
    {
35
        $this->operations[$operation->getName()] = $operation;
36
    }
37
38
    public function getClient(): SyncWebServiceClientInterface
39
    {
40
        if ($this->client === null) {
41
            // TODO refactor to use configuration
42
            $factory = ReflectUtil::instantiate(ProcessEngineConfigurationImpl::DEFAULT_WS_SYNC_FACTORY);
0 ignored issues
show
The constant Jabe\Impl\Cfg\ProcessEng...DEFAULT_WS_SYNC_FACTORY was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
43
            $this->client = $factory->create($this->wsdlLocation);
44
        }
45
        return $this->client;
46
    }
47
48
    public function getName(): string
49
    {
50
        return $this->name;
51
    }
52
53
    public function getLocation(): string
54
    {
55
        return $this->location;
56
    }
57
}
58