Passed
Pull Request — master (#33)
by Aleksey
09:12 queued 01:09
created

NotificationProcessor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 44
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A executeSaveComputopNotificationTransaction() 0 5 1
A __construct() 0 3 1
A processNotification() 0 10 1
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Computop\Business\Processor;
9
10
use Generated\Shared\Transfer\ComputopNotificationTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...topNotificationTransfer 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 Spryker\Zed\Kernel\Persistence\EntityManager\TransactionTrait;
12
use SprykerEco\Zed\Computop\Persistence\ComputopEntityManagerInterface;
13
14
class NotificationProcessor implements NotificationProcessorInterface
15
{
16
    use TransactionTrait;
17
18
    /**
19
     * @var \SprykerEco\Zed\Computop\Persistence\ComputopEntityManagerInterface
20
     */
21
    protected $computopEntityManager;
22
23
    /**
24
     * @param \SprykerEco\Zed\Computop\Persistence\ComputopEntityManagerInterface $computopEntityManager
25
     */
26
    public function __construct(ComputopEntityManagerInterface $computopEntityManager)
27
    {
28
        $this->computopEntityManager = $computopEntityManager;
29
    }
30
31
    /**
32
     * @param \Generated\Shared\Transfer\ComputopNotificationTransfer $computopNotificationTransfer
33
     *
34
     * @return \Generated\Shared\Transfer\ComputopNotificationTransfer
35
     */
36
    public function processNotification(
37
        ComputopNotificationTransfer $computopNotificationTransfer
38
    ): ComputopNotificationTransfer {
39
        $this->getTransactionHandler()->handleTransaction(
40
            function () use ($computopNotificationTransfer): void {
41
                $this->executeSaveComputopNotificationTransaction($computopNotificationTransfer);
42
            }
43
        );
44
45
        return $computopNotificationTransfer;
46
    }
47
48
    /**
49
     * @param \Generated\Shared\Transfer\ComputopNotificationTransfer $computopNotificationTransfer
50
     *
51
     * @return void
52
     */
53
    protected function executeSaveComputopNotificationTransaction(
54
        ComputopNotificationTransfer $computopNotificationTransfer
55
    ): void {
56
        $this->computopEntityManager->savePaymentComputopNotification($computopNotificationTransfer);
57
        $this->computopEntityManager->updatePaymentComputopOrderItemPaymentConfirmation($computopNotificationTransfer);
58
    }
59
}
60