Completed
Push — master ( d47f9a...e8ab44 )
by Oleksandr
15s queued 12s
created

ArvatoRssEntityManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 22
dl 0
loc 56
rs 10
c 2
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A saveArvatoRssApiLogEntity() 0 14 1
A updateArvatoRssApiLogEntity() 0 18 1
A getMapper() 0 3 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\ArvatoRss\Persistence;
9
10
use Generated\Shared\Transfer\ArvatoRssApiCallLogTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...toRssApiCallLogTransfer 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 Orm\Zed\ArvatoRss\Persistence\SpyArvatoRssApiCallLog;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\ArvatoRss\Persis...\SpyArvatoRssApiCallLog 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 Spryker\Zed\Kernel\Persistence\AbstractEntityManager;
13
use SprykerEco\Zed\ArvatoRss\Persistence\Mapper\ArvatoRssPersistenceMapper;
14
15
/**
16
 * @method \SprykerEco\Zed\ArvatoRss\Persistence\ArvatoRssPersistenceFactory getFactory()
17
 */
18
class ArvatoRssEntityManager extends AbstractEntityManager implements ArvatoRssEntityManagerInterface
19
{
20
    /**
21
     * @param \Generated\Shared\Transfer\ArvatoRssApiCallLogTransfer $arvatoRssApiCallLogTransfer
22
     *
23
     * @return \Generated\Shared\Transfer\ArvatoRssApiCallLogTransfer
24
     */
25
    public function saveArvatoRssApiLogEntity(ArvatoRssApiCallLogTransfer $arvatoRssApiCallLogTransfer): ArvatoRssApiCallLogTransfer
26
    {
27
        $arvatoRssApiCallLogEntity = new SpyArvatoRssApiCallLog();
28
29
        $arvatoRssApiCallLogEntity->fromArray(
30
            $arvatoRssApiCallLogTransfer->modifiedToArray()
31
        );
32
33
        $arvatoRssApiCallLogEntity->save();
34
35
        return $this->getMapper()
36
            ->mapEntityToArvatoRssApiCallLogTransfer(
37
                $arvatoRssApiCallLogEntity,
38
                $arvatoRssApiCallLogTransfer
39
            );
40
    }
41
42
    /**
43
     * @param \Generated\Shared\Transfer\ArvatoRssApiCallLogTransfer $arvatoRssApiCallLogTransfer
44
     *
45
     * @return \Generated\Shared\Transfer\ArvatoRssApiCallLogTransfer
46
     */
47
    public function updateArvatoRssApiLogEntity(ArvatoRssApiCallLogTransfer $arvatoRssApiCallLogTransfer): ArvatoRssApiCallLogTransfer
48
    {
49
        $arvatoRssApiCallLogEntity = $this->getFactory()
50
            ->createArvatoRssApiCallLogQuery()
51
            ->filterByCommunicationToken($arvatoRssApiCallLogTransfer->getCommunicationToken())
52
            ->filterByCallType($arvatoRssApiCallLogTransfer->getCallType())
53
            ->findOneOrCreate();
54
55
        $arvatoRssApiCallLogEntity->fromArray(
56
            $arvatoRssApiCallLogTransfer->modifiedToArray()
57
        );
58
59
        $arvatoRssApiCallLogEntity->save();
60
61
        return $this->getMapper()
62
            ->mapEntityToArvatoRssApiCallLogTransfer(
63
                $arvatoRssApiCallLogEntity,
64
                $arvatoRssApiCallLogTransfer
65
            );
66
    }
67
68
    /**
69
     * @return \SprykerEco\Zed\ArvatoRss\Persistence\Mapper\ArvatoRssPersistenceMapper
70
     */
71
    protected function getMapper(): ArvatoRssPersistenceMapper
72
    {
73
        return $this->getFactory()->createArvatoRssPersistenceMapper();
74
    }
75
}
76