Completed
Push — master ( cddd98...c8ab6f )
by Oleksandr
14s queued 10s
created

PaymentTransactionMetaVisitor::getPaymentEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
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\Braintree\Business\Payment\Transaction\MetaVisitor;
9
10
use Generated\Shared\Transfer\PaymentBraintreeTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PaymentBraintreeTransfer 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 Generated\Shared\Transfer\TransactionMetaTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\TransactionMetaTransfer 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\Zed\Braintree\Persistence\BraintreeRepositoryInterface;
13
14
class PaymentTransactionMetaVisitor implements TransactionMetaVisitorInterface
15
{
16
    /**
17
     * @var \SprykerEco\Zed\Braintree\Persistence\BraintreeRepositoryInterface
18
     */
19
    protected $repository;
20
21
    /**
22
     * @param \SprykerEco\Zed\Braintree\Persistence\BraintreeRepositoryInterface $repository
23
     */
24
    public function __construct(BraintreeRepositoryInterface $repository)
25
    {
26
        $this->repository = $repository;
27
    }
28
29
    /**
30
     * @param \Generated\Shared\Transfer\TransactionMetaTransfer $transactionMetaTransfer
31
     *
32
     * @return void
33
     */
34
    public function visit(TransactionMetaTransfer $transactionMetaTransfer)
35
    {
36
        $paymentBraintreeTransfer = $this->findPaymentBraintreeTransfer($transactionMetaTransfer);
37
38
        if ($paymentBraintreeTransfer) {
39
            $transactionMetaTransfer->setIdPayment($paymentBraintreeTransfer->getIdPaymentBraintree());
40
            $transactionMetaTransfer->setTransactionIdentifier($paymentBraintreeTransfer->getTransactionId());
41
        }
42
    }
43
44
    /**
45
     * @param \Generated\Shared\Transfer\TransactionMetaTransfer $transactionMetaTransfer
46
     *
47
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransfer|null
48
     */
49
    protected function findPaymentBraintreeTransfer(TransactionMetaTransfer $transactionMetaTransfer): ?PaymentBraintreeTransfer
50
    {
51
        $idSalesOrderEntity = $transactionMetaTransfer->requireIdSalesOrder()->getIdSalesOrder();
52
53
        return $this->repository->findPaymentBraintreeBySalesOrderId($idSalesOrderEntity);
54
    }
55
}
56