Completed
Push — master ( 56a686...736967 )
by Oleksandr
15s queued 11s
created

RegistrationWriter::fetchRegistrationFromQuote()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
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\Heidelpay\Business\Payment\CreditCard\Registration;
9
10
use Generated\Shared\Transfer\QuoteTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer 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\Heidelpay\Persistence\SpyPaymentHeidelpayCreditCardRegistration;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\Heidelpay\Persis...yCreditCardRegistration 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\Heidelpay\Persistence\HeidelpayQueryContainerInterface;
13
14
class RegistrationWriter implements RegistrationWriterInterface
15
{
16
    /**
17
     * @var \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayQueryContainerInterface
18
     */
19
    protected $heidelpayQueryContainer;
20
21
    /**
22
     * @param \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayQueryContainerInterface $heidelpayQueryContainer
23
     */
24
    public function __construct(HeidelpayQueryContainerInterface $heidelpayQueryContainer)
25
    {
26
        $this->heidelpayQueryContainer = $heidelpayQueryContainer;
27
    }
28
29
    /**
30
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
31
     *
32
     * @return void
33
     */
34
    public function updateRegistrationWithAddressIdFromQuote(QuoteTransfer $quoteTransfer): void
35
    {
36
        $registrationEntity = $this->findRegistrationFromQuote($quoteTransfer);
37
38
        if ($registrationEntity !== null) {
39
            $registrationEntity
40
                ->setFkCustomerAddress(
41
                    $quoteTransfer->getShippingAddress()->getIdCustomerAddress()
42
                )
43
                ->save();
44
        }
45
    }
46
47
    /**
48
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
49
     *
50
     * @return \Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpayCreditCardRegistration
51
     */
52
    protected function findRegistrationFromQuote(QuoteTransfer $quoteTransfer): SpyPaymentHeidelpayCreditCardRegistration
53
    {
54
        $registrationHash = $quoteTransfer
55
            ->getPayment()
56
            ->getHeidelpayCreditCardSecure()
57
            ->getSelectedRegistration()
58
            ->getRegistrationNumber();
59
60
        $registrationEntity = $this->heidelpayQueryContainer
61
            ->queryCreditCardRegistrationByRegistrationNumber(
62
                $registrationHash
63
            )
64
            ->findOne();
65
66
        return $registrationEntity;
67
    }
68
}
69