PaymentAuthorizationTimeOutChecker   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A check() 0 7 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\FirstData\Business\Checker;
9
10
use DateInterval;
11
use DateTime;
12
use Generated\Shared\Transfer\OrderTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\OrderTransfer 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 SprykerEco\Zed\FirstData\FirstDataConfig;
14
15
class PaymentAuthorizationTimeOutChecker implements PaymentAuthorizationTimeOutCheckerInterface
16
{
17
    /**
18
     * @var \SprykerEco\Zed\FirstData\FirstDataConfig
19
     */
20
    protected $firstDataConfig;
21
22
    /**
23
     * @param \SprykerEco\Zed\FirstData\FirstDataConfig $firstDataConfig
24
     */
25
    public function __construct(FirstDataConfig $firstDataConfig)
26
    {
27
        $this->firstDataConfig = $firstDataConfig;
28
    }
29
30
    /**
31
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
32
     *
33
     * @return bool
34
     */
35
    public function check(OrderTransfer $orderTransfer): bool
36
    {
37
        $paymentAuthTimedOutDateTime = new DateTime($orderTransfer->getCreatedAtOrFail());
38
        $interval = DateInterval::createFromDateString($this->firstDataConfig->getPaymentAuthorizationTimeOut());
39
        $paymentAuthTimedOutDateTime->add($interval);
40
41
        return new DateTime() > $paymentAuthTimedOutDateTime;
42
    }
43
}
44