EasycreditLogger   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A saveApiLog() 0 15 2
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\Easycredit\Business\Logger;
9
10
use Generated\Shared\Transfer\EasycreditRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...sycreditRequestTransfer 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\EasycreditResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ycreditResponseTransfer 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\PaymentEasycreditApiLogTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...asycreditApiLogTransfer 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\Easycredit\Persistence\EasycreditEntityManagerInterface;
14
15
class EasycreditLogger implements EasycreditLoggerInterface
16
{
17
    /**
18
     * @var \SprykerEco\Zed\Easycredit\Persistence\EasycreditEntityManagerInterface
19
     */
20
    protected $entityManager;
21
22
    /**
23
     * @param \SprykerEco\Zed\Easycredit\Persistence\EasycreditEntityManagerInterface $entityManager
24
     */
25
    public function __construct(
26
        EasycreditEntityManagerInterface $entityManager
27
    ) {
28
        $this->entityManager = $entityManager;
29
    }
30
31
    /**
32
     * @param string $type
33
     * @param \Generated\Shared\Transfer\EasycreditRequestTransfer $easycreditRequestTransfer
34
     * @param \Generated\Shared\Transfer\EasycreditResponseTransfer $easycreditResponseTransfer
35
     *
36
     * @return \Generated\Shared\Transfer\PaymentEasycreditApiLogTransfer
37
     */
38
    public function saveApiLog(string $type, EasycreditRequestTransfer $easycreditRequestTransfer, EasycreditResponseTransfer $easycreditResponseTransfer): PaymentEasycreditApiLogTransfer
39
    {
40
        $paymentEasycreditApiLog = (new PaymentEasycreditApiLogTransfer())
41
            ->setType($type)
42
            ->setRequest($easycreditRequestTransfer->serialize())
43
            ->setResponse($easycreditResponseTransfer->serialize());
44
45
        if ($easycreditResponseTransfer->getError()) {
46
            $paymentEasycreditApiLog
47
                ->setStatusCode($easycreditResponseTransfer->getError()->getStatusCode())
48
                ->setErrorCode($easycreditResponseTransfer->getError()->getErrorCode())
49
                ->setErrorMessage($easycreditResponseTransfer->getError()->getErrorMessage());
50
        }
51
52
        return $this->entityManager->saveEasycreditApiLog($paymentEasycreditApiLog);
53
    }
54
}
55