Completed
Push — master ( d47f9a...e8ab44 )
by Oleksandr
15s queued 12s
created

ArvatoRssWriter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 6
rs 10
c 1
b 1
f 0
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\Writer;
9
10
use SprykerEco\Shared\ArvatoRss\ArvatoRssApiConfig;
11
use SprykerEco\Zed\ArvatoRss\Persistence\ArvatoRssEntityManagerInterface;
12
use SprykerEco\Zed\ArvatoRss\Persistence\ArvatoRssRepositoryInterface;
13
14
class ArvatoRssWriter implements ArvatoRssWriterInterface
15
{
16
    /**
17
     * @var \SprykerEco\Zed\ArvatoRss\Persistence\ArvatoRssRepositoryInterface
18
     */
19
    protected $repository;
20
21
    /**
22
     * @var \SprykerEco\Zed\ArvatoRss\Persistence\ArvatoRssEntityManagerInterface
23
     */
24
    protected $entityManager;
25
26
    /**
27
     * @param \SprykerEco\Zed\ArvatoRss\Persistence\ArvatoRssRepositoryInterface $repository
28
     * @param \SprykerEco\Zed\ArvatoRss\Persistence\ArvatoRssEntityManagerInterface $entityManager
29
     */
30
    public function __construct(
31
        ArvatoRssRepositoryInterface $repository,
32
        ArvatoRssEntityManagerInterface $entityManager
33
    ) {
34
        $this->repository = $repository;
35
        $this->entityManager = $entityManager;
36
    }
37
38
    /**
39
     * @param string $communicationToken
40
     * @param string $orderReference
41
     *
42
     * @return void
43
     */
44
    public function updateLogWithOrderReference(string $communicationToken, string $orderReference): void
45
    {
46
        $apiLogTransfer = $this->repository
47
            ->findApiLogByCommunicationTokenAndType(
48
                $communicationToken,
49
                ArvatoRssApiConfig::TRANSACTION_TYPE_RISK_CHECK
50
            );
51
52
        if ($apiLogTransfer === null) {
53
            return;
54
        }
55
56
        $apiLogTransfer->setOrderReference($orderReference);
57
58
        $this->entityManager->updateArvatoRssApiLogEntity($apiLogTransfer);
59
    }
60
}
61