Completed
Pull Request — master (#3)
by Aleksey
15:31 queued 12:58
created

savePaymentCrefoPayApiLog()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 13
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 19
rs 9.8333
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\CrefoPayApi\Persistence;
9
10
use Generated\Shared\Transfer\PaymentCrefoPayApiLogTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...tCrefoPayApiLogTransfer 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\AbstractEntityManager;
12
use SprykerEco\Zed\CrefoPayApi\Persistence\Mapper\CrefoPayApiPersistenceMapper;
13
14
/**
15
 * @method \SprykerEco\Zed\CrefoPayApi\Persistence\CrefoPayApiPersistenceFactory getFactory()
16
 */
17
class CrefoPayApiEntityManager extends AbstractEntityManager implements CrefoPayApiEntityManagerInterface
18
{
19
    /**
20
     * @param \Generated\Shared\Transfer\PaymentCrefoPayApiLogTransfer $paymentCrefoPayApiLogTransfer
21
     *
22
     * @return \Generated\Shared\Transfer\PaymentCrefoPayApiLogTransfer
23
     */
24
    public function savePaymentCrefoPayApiLog(
25
        PaymentCrefoPayApiLogTransfer $paymentCrefoPayApiLogTransfer
26
    ): PaymentCrefoPayApiLogTransfer {
27
        $paymentCrefoPayApiLogEntity = $this->getFactory()
28
            ->createPaymentCrefoPayApiLogQuery()
29
            ->filterByRequestType($paymentCrefoPayApiLogTransfer->getRequestType())
30
            ->filterByCrefoPayOrderId($paymentCrefoPayApiLogTransfer->getCrefoPayOrderId())
31
            ->filterBySalt($paymentCrefoPayApiLogTransfer->getSalt())
32
            ->findOneOrCreate();
33
34
        $paymentCrefoPayApiLogEntity->fromArray(
35
            $paymentCrefoPayApiLogTransfer->modifiedToArray()
36
        );
37
        $paymentCrefoPayApiLogEntity->save();
38
39
        return $this->getMapper()
40
            ->mapEntityToPaymentCrefoPayApiLogTransfer(
41
                $paymentCrefoPayApiLogEntity,
42
                $paymentCrefoPayApiLogTransfer
43
            );
44
    }
45
46
    /**
47
     * @return \SprykerEco\Zed\CrefoPayApi\Persistence\Mapper\CrefoPayApiPersistenceMapper
48
     */
49
    protected function getMapper(): CrefoPayApiPersistenceMapper
50
    {
51
        return $this->getFactory()->createCrefoPayApiPersistenceMapper();
52
    }
53
}
54