Passed
Push — master ( 2944ee...dfe2d2 )
by Asmir
02:04
created

DevMetadataLoader::load()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 12
rs 10
cc 3
nc 3
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GoetasWebservices\SoapServices\Metadata\Loader;
6
7
use GoetasWebservices\SoapServices\Exception\MetadataException;
0 ignored issues
show
Bug introduced by
The type GoetasWebservices\SoapSe...ption\MetadataException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use GoetasWebservices\SoapServices\Metadata\Generator\MetadataGenerator;
9
use GoetasWebservices\XML\SOAPReader\SoapReader;
0 ignored issues
show
Bug introduced by
The type GoetasWebservices\XML\SOAPReader\SoapReader was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use GoetasWebservices\XML\WSDLReader\DefinitionsReader;
0 ignored issues
show
Bug introduced by
The type GoetasWebservices\XML\WSDLReader\DefinitionsReader was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
/**
13
 * This class is here to be used only while developing, should not be used on production.
14
 */
15
class DevMetadataLoader implements MetadataLoaderInterface
16
{
17
    /**
18
     * @var array
19
     */
20
    private $metadataCache = [];
21
    /**
22
     * @var MetadataGenerator
23
     */
24
    private $metadataGenerator;
25
    /**
26
     * @var DefinitionsReader
27
     */
28
    private $wsdlReader;
29
    /**
30
     * @var SoapReader
31
     */
32
    private $soapReader;
33
34
    public function __construct(MetadataGenerator $metadataGenerator, SoapReader $soapReader, DefinitionsReader $wsdlReader)
35
    {
36
        $this->metadataGenerator = $metadataGenerator;
37
        $this->wsdlReader = $wsdlReader;
38
        $this->soapReader = $soapReader;
39
    }
40
41
    public function load(string $wsdl): array
42
    {
43
        if (!isset($this->metadataCache[$wsdl])) {
44
            $this->wsdlReader->readFile($wsdl);
45
            try {
46
                $this->metadataCache[$wsdl] = $this->metadataGenerator->generate($this->soapReader->getServices());
47
            } catch (\Throwable $e) {
48
                throw new MetadataException(sprintf('Can not generate metadata information for %s', $wsdl), 0, $e);
49
            }
50
        }
51
52
        return $this->metadataCache[$wsdl];
53
    }
54
}
55