TransactionLogReader::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
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\AfterPay\Business\Payment\Transaction;
9
10
use Generated\Shared\Transfer\AfterPayTransactionLogTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...yTransactionLogTransfer 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 Orm\Zed\AfterPay\Persistence\SpyPaymentAfterPayTransactionLog;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\AfterPay\Persist...tAfterPayTransactionLog 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...
12
use SprykerEco\Shared\AfterPay\AfterPayConfig;
13
use SprykerEco\Zed\AfterPay\Persistence\AfterPayQueryContainerInterface;
14
15
class TransactionLogReader implements TransactionLogReaderInterface
16
{
17
    public const TRANSACTION_TYPE_AUTHORIZE = AfterPayConfig::TRANSACTION_TYPE_AUTHORIZE;
18
19
    /**
20
     * @var \SprykerEco\Zed\AfterPay\Persistence\AfterPayQueryContainerInterface
21
     */
22
    protected $queryContainer;
23
24
    /**
25
     * @param \SprykerEco\Zed\AfterPay\Persistence\AfterPayQueryContainerInterface $queryContainer
26
     */
27
    public function __construct(AfterPayQueryContainerInterface $queryContainer)
28
    {
29
        $this->queryContainer = $queryContainer;
30
    }
31
32
    /**
33
     * @param string $orderReference
34
     *
35
     * @return \Generated\Shared\Transfer\AfterPayTransactionLogTransfer|null
36
     */
37
    public function findOrderAuthorizeTransactionLogByIdSalesOrder(string $orderReference): ?AfterPayTransactionLogTransfer
38
    {
39
        $spyTransactionLog = $this->findOrderAuthorizeTransactionEntity($orderReference);
40
41
        if ($spyTransactionLog === null) {
42
            return null;
43
        }
44
45
        return $this->buildTransactionTransfer($spyTransactionLog);
46
    }
47
48
    /**
49
     * @param string $orderReference
50
     *
51
     * @return \Orm\Zed\AfterPay\Persistence\SpyPaymentAfterPayTransactionLog|null
52
     */
53
    protected function findOrderAuthorizeTransactionEntity(string $orderReference): ?SpyPaymentAfterPayTransactionLog
54
    {
55
        $transactionLogEntity = $this->queryContainer
56
            ->queryTransactionByIdSalesOrderAndType($orderReference, static::TRANSACTION_TYPE_AUTHORIZE)
57
            ->findOne();
58
59
        return $transactionLogEntity;
60
    }
61
62
    /**
63
     * @param \Orm\Zed\AfterPay\Persistence\SpyPaymentAfterPayTransactionLog $transactionLogEntry
64
     *
65
     * @return \Generated\Shared\Transfer\AfterPayTransactionLogTransfer
66
     */
67
    protected function buildTransactionTransfer(SpyPaymentAfterPayTransactionLog $transactionLogEntry): AfterPayTransactionLogTransfer
68
    {
69
        return (new AfterPayTransactionLogTransfer())
70
            ->fromArray($transactionLogEntry->toArray(), true);
71
    }
72
}
73