ClickEventTracker   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 13
c 1
b 0
f 0
dl 0
loc 47
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A track() 0 10 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\Client\FactFinderNg\EventTracker;
9
10
use Generated\Shared\Transfer\FactFinderNgResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...inderNgResponseTransfer 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 SprykerEco\Client\FactFinderNg\Api\Adapter\Http\Factory\AdapterFactoryInterface;
12
use SprykerEco\Client\FactFinderNg\Mapper\Request\FactFinderNgRequestMapperInterface;
13
use SprykerEco\Client\FactFinderNg\Parser\ResponseParserInterface;
14
15
class ClickEventTracker implements EventTrackerInterface
16
{
17
    /**
18
     * @var \SprykerEco\Client\FactFinderNg\Mapper\Request\FactFinderNgRequestMapperInterface
19
     */
20
    protected $requestMapper;
21
22
    /**
23
     * @var \SprykerEco\Client\FactFinderNg\Api\Adapter\Http\Factory\AdapterFactoryInterface
24
     */
25
    protected $adapterFactory;
26
27
    /**
28
     * @var \SprykerEco\Client\FactFinderNg\Parser\ResponseParserInterface
29
     */
30
    protected $responseParser;
31
32
    /**
33
     * @param \SprykerEco\Client\FactFinderNg\Mapper\Request\FactFinderNgRequestMapperInterface $requestMapper
34
     * @param \SprykerEco\Client\FactFinderNg\Api\Adapter\Http\Factory\AdapterFactoryInterface $adapterFactory
35
     * @param \SprykerEco\Client\FactFinderNg\Parser\ResponseParserInterface $responseParser
36
     */
37
    public function __construct(
38
        FactFinderNgRequestMapperInterface $requestMapper,
39
        AdapterFactoryInterface $adapterFactory,
40
        ResponseParserInterface $responseParser
41
    ) {
42
        $this->requestMapper = $requestMapper;
43
        $this->adapterFactory = $adapterFactory;
44
        $this->responseParser = $responseParser;
45
    }
46
47
    /**
48
     * @param \Generated\Shared\Transfer\ClickEventTransfer[] $eventTransfers
49
     *
50
     * @return \Generated\Shared\Transfer\FactFinderNgResponseTransfer
51
     */
52
    public function track(array $eventTransfers): FactFinderNgResponseTransfer
53
    {
54
        $trackCheckoutRequestTransfer = $this->requestMapper
55
            ->mapTrackClickEventRequest($eventTransfers);
56
57
        $response = $this->adapterFactory
58
            ->createFactFinderNgTrackClickApiAdapter()
59
            ->sendRequest($trackCheckoutRequestTransfer);
60
61
        return $this->responseParser->parseResponse($response);
62
    }
63
}
64