RequestHeaderConverter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 59
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createRequestData() 0 15 1
A convert() 0 5 1
A createRequestHeader() 0 6 1
A getRequestFields() 0 6 1
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\ArvatoRss\Business\Api\Converter;
9
10
use Generated\Shared\Transfer\ArvatoRssIdentificationRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ficationRequestTransfer 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
use SoapHeader;
12
use SprykerEco\Zed\ArvatoRss\Business\Api\ArvatoRssIdentificationApiConfig;
13
14
class RequestHeaderConverter implements RequestHeaderConverterInterface
15
{
16
    /**
17
     * @param \Generated\Shared\Transfer\ArvatoRssIdentificationRequestTransfer $arvatoRssIdentificationRequestTransfer
18
     *
19
     * @return \SoapHeader
20
     */
21
    public function convert(ArvatoRssIdentificationRequestTransfer $arvatoRssIdentificationRequestTransfer)
22
    {
23
        $requestData = $this->createRequestData($arvatoRssIdentificationRequestTransfer);
24
25
        return $this->createRequestHeader($requestData);
26
    }
27
28
    /**
29
     * @param \Generated\Shared\Transfer\ArvatoRssIdentificationRequestTransfer $arvatoRssIdentificationRequestTransfer
30
     *
31
     * @return array
32
     */
33
    protected function createRequestData(ArvatoRssIdentificationRequestTransfer $arvatoRssIdentificationRequestTransfer)
34
    {
35
        $result = [];
36
        $fields = $this->getRequestFields();
37
        array_walk($fields, function (
38
            $item,
39
            $key
40
        ) use (
41
            &$result,
42
            $arvatoRssIdentificationRequestTransfer
43
        ) {
44
            $result[$key] = $arvatoRssIdentificationRequestTransfer->{'get' . ucfirst($item)}();
45
        });
46
47
        return $result;
48
    }
49
50
    /**
51
     * @param array $requestData
52
     *
53
     * @return \SoapHeader
54
     */
55
    protected function createRequestHeader($requestData)
56
    {
57
        return new SoapHeader(
58
            ArvatoRssIdentificationApiConfig::ARVATORSS_API_IDENTIFICATION_NAMESPACE,
59
            ArvatoRssIdentificationApiConfig::ARVATORSS_API_IDENTIFICATION_HEADER_NAME,
60
            $requestData
61
        );
62
    }
63
64
    /**
65
     * @return array
66
     */
67
    protected function getRequestFields()
68
    {
69
        return [
70
            ArvatoRssIdentificationApiConfig::ARVATORSS_API_CLIENTID => 'clientId',
71
            ArvatoRssIdentificationApiConfig::ARVATORSS_API_AUTHORISATION => 'authorisation',
72
            ArvatoRssIdentificationApiConfig::ARVATORSS_API_COMMUNICATION_TOKEN => 'communicationToken',
73
        ];
74
    }
75
}
76