Passed
Pull Request — master (#9)
by Volodymyr
08:30
created

BraintreePersistenceMapper   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 87
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A mapEntityToPaymentBraintreeTransactionRequestLogTransfer() 0 5 1
A mapEntityToPaymentBraintreeTransactionStatusLogTransfer() 0 5 1
A mapPaymentBraintreeTransactionStatusLogTransferToEntity() 0 8 1
A mapPaymentBraintreeTransferToEntity() 0 8 1
A mapEntityToPaymentBraintreeTransfer() 0 5 1
A mapPaymentBraintreeTransactionRequestLogTransferToEntity() 0 8 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\Zed\Braintree\Persistence\Mapper;
9
10
use Generated\Shared\Transfer\PaymentBraintreeTransactionRequestLogTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ctionRequestLogTransfer 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\PaymentBraintreeTransactionStatusLogTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...actionStatusLogTransfer 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 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...
13
use Orm\Zed\Braintree\Persistence\SpyPaymentBraintree;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Braintree\Persistence\SpyPaymentBraintree 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...
14
use Orm\Zed\Braintree\Persistence\SpyPaymentBraintreeTransactionRequestLog;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Braintree\Persis...eeTransactionRequestLog 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...
15
use Orm\Zed\Braintree\Persistence\SpyPaymentBraintreeTransactionStatusLog;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Braintree\Persis...reeTransactionStatusLog 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...
16
17
class BraintreePersistenceMapper implements BraintreePersistenceMapperInterface
18
{
19
    /**
20
     * @param \Generated\Shared\Transfer\PaymentBraintreeTransfer $paymentBraintreeTransfer
21
     * @param \Orm\Zed\Braintree\Persistence\SpyPaymentBraintree $paymentBraintreeEntity
22
     *
23
     * @return \Orm\Zed\Braintree\Persistence\SpyPaymentBraintree
24
     */
25
    public function mapPaymentBraintreeTransferToEntity(
26
        PaymentBraintreeTransfer $paymentBraintreeTransfer,
27
        SpyPaymentBraintree $paymentBraintreeEntity
28
    ): SpyPaymentBraintree {
29
        $paymentBraintreeEntity->fromArray($paymentBraintreeTransfer->modifiedToArray());
30
        $paymentBraintreeEntity->setNew($paymentBraintreeTransfer->getIdPaymentBraintree() === null);
31
32
        return $paymentBraintreeEntity;
33
    }
34
35
    /**
36
     * @param \Orm\Zed\Braintree\Persistence\SpyPaymentBraintree $paymentBraintreeEntity
37
     * @param \Generated\Shared\Transfer\PaymentBraintreeTransfer $paymentBraintreeTransfer
38
     *
39
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransfer
40
     */
41
    public function mapEntityToPaymentBraintreeTransfer(
42
        SpyPaymentBraintree $paymentBraintreeEntity,
43
        PaymentBraintreeTransfer $paymentBraintreeTransfer
44
    ): PaymentBraintreeTransfer {
45
        return $paymentBraintreeTransfer->fromArray($paymentBraintreeEntity->toArray(), true);
46
    }
47
48
    /**
49
     * @param \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer $paymentBraintreeTransactionStatusLogTransfer
50
     * @param \Orm\Zed\Braintree\Persistence\SpyPaymentBraintreeTransactionStatusLog $paymentBraintreeTransactionStatusLogEntity
51
     *
52
     * @return \Orm\Zed\Braintree\Persistence\SpyPaymentBraintreeTransactionStatusLog
53
     */
54
    public function mapPaymentBraintreeTransactionStatusLogTransferToEntity(
55
        PaymentBraintreeTransactionStatusLogTransfer $paymentBraintreeTransactionStatusLogTransfer,
56
        SpyPaymentBraintreeTransactionStatusLog $paymentBraintreeTransactionStatusLogEntity
57
    ): SpyPaymentBraintreeTransactionStatusLog {
58
        $paymentBraintreeTransactionStatusLogEntity->fromArray($paymentBraintreeTransactionStatusLogTransfer->modifiedToArray());
59
        $paymentBraintreeTransactionStatusLogEntity->setNew($paymentBraintreeTransactionStatusLogTransfer->getIdPaymentBraintreeTransactionStatusLog() === null);
60
61
        return $paymentBraintreeTransactionStatusLogEntity;
62
    }
63
64
    /**
65
     * @param \Orm\Zed\Braintree\Persistence\SpyPaymentBraintreeTransactionStatusLog $paymentBraintreeTransactionStatusLogEntity
66
     * @param \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer $paymentBraintreeTransactionStatusLogTransfer
67
     *
68
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer
69
     */
70
    public function mapEntityToPaymentBraintreeTransactionStatusLogTransfer(
71
        SpyPaymentBraintreeTransactionStatusLog $paymentBraintreeTransactionStatusLogEntity,
72
        PaymentBraintreeTransactionStatusLogTransfer $paymentBraintreeTransactionStatusLogTransfer
73
    ): PaymentBraintreeTransactionStatusLogTransfer {
74
        return $paymentBraintreeTransactionStatusLogTransfer->fromArray($paymentBraintreeTransactionStatusLogEntity->toArray(), true);
75
    }
76
77
    /**
78
     * @param \Generated\Shared\Transfer\PaymentBraintreeTransactionRequestLogTransfer $paymentBraintreeTransactionRequestLogTransfer
79
     * @param \Orm\Zed\Braintree\Persistence\SpyPaymentBraintreeTransactionRequestLog $paymentBraintreeTransactionRequestLogEntity
80
     *
81
     * @return \Orm\Zed\Braintree\Persistence\SpyPaymentBraintreeTransactionRequestLog
82
     */
83
    public function mapPaymentBraintreeTransactionRequestLogTransferToEntity(
84
        PaymentBraintreeTransactionRequestLogTransfer $paymentBraintreeTransactionRequestLogTransfer,
85
        SpyPaymentBraintreeTransactionRequestLog $paymentBraintreeTransactionRequestLogEntity
86
    ): SpyPaymentBraintreeTransactionRequestLog {
87
        $paymentBraintreeTransactionRequestLogEntity->fromArray($paymentBraintreeTransactionRequestLogTransfer->modifiedToArray());
88
        $paymentBraintreeTransactionRequestLogEntity->setNew($paymentBraintreeTransactionRequestLogTransfer->getIdPaymentBraintreeTransactionRequestLog() === null);
89
90
        return $paymentBraintreeTransactionRequestLogEntity;
91
    }
92
93
    /**
94
     * @param \Orm\Zed\Braintree\Persistence\SpyPaymentBraintreeTransactionRequestLog $paymentBraintreeTransactionRequestLogEntity
95
     * @param \Generated\Shared\Transfer\PaymentBraintreeTransactionRequestLogTransfer $paymentBraintreeTransactionRequestLogTransfer
96
     *
97
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionRequestLogTransfer
98
     */
99
    public function mapEntityToPaymentBraintreeTransactionRequestLogTransfer(
100
        SpyPaymentBraintreeTransactionRequestLog $paymentBraintreeTransactionRequestLogEntity,
101
        PaymentBraintreeTransactionRequestLogTransfer $paymentBraintreeTransactionRequestLogTransfer
102
    ): PaymentBraintreeTransactionRequestLogTransfer {
103
        return $paymentBraintreeTransactionRequestLogTransfer->fromArray($paymentBraintreeTransactionRequestLogEntity->toArray(), true);
104
    }
105
}
106