PunchoutCatalogsConnectionMapper::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\PunchoutCatalogs\Persistence\Propel\Mapper;
9
10
use Generated\Shared\Transfer\PunchoutCatalogConnectionCartTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...gConnectionCartTransfer 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\PunchoutCatalogConnectionSetupTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ConnectionSetupTransfer 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\PunchoutCatalogConnectionTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...talogConnectionTransfer 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 Generated\Shared\Transfer\PunchoutCatalogTransactionTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...alogTransactionTransfer 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...
14
use Orm\Zed\PunchoutCatalog\Persistence\PgwPunchoutCatalogConnection;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\PunchoutCatalog\...nchoutCatalogConnection 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...
15
use Orm\Zed\PunchoutCatalog\Persistence\PgwPunchoutCatalogTransaction;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\PunchoutCatalog\...choutCatalogTransaction 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...
16
17
class PunchoutCatalogsConnectionMapper
18
{
19
    /**
20
     * @var \SprykerEco\Zed\PunchoutCatalogs\Persistence\Propel\Mapper\PunchoutCatalogsConnectionSetupMapper
21
     */
22
    protected $punchoutCatalogConnectionSetupMapper;
23
24
    /**
25
     * @var \SprykerEco\Zed\PunchoutCatalogs\Persistence\Propel\Mapper\PunchoutCatalogsConnectionCartMapper
26
     */
27
    protected $punchoutCatalogConnectionCartMapper;
28
29
    /**
30
     * @param \SprykerEco\Zed\PunchoutCatalogs\Persistence\Propel\Mapper\PunchoutCatalogsConnectionSetupMapper $punchoutCatalogConnectionSetupMapper
31
     * @param \SprykerEco\Zed\PunchoutCatalogs\Persistence\Propel\Mapper\PunchoutCatalogsConnectionCartMapper $punchoutCatalogConnectionCartMapper
32
     */
33
    public function __construct(PunchoutCatalogsConnectionSetupMapper $punchoutCatalogConnectionSetupMapper, PunchoutCatalogsConnectionCartMapper $punchoutCatalogConnectionCartMapper)
34
    {
35
        $this->punchoutCatalogConnectionSetupMapper = $punchoutCatalogConnectionSetupMapper;
36
        $this->punchoutCatalogConnectionCartMapper = $punchoutCatalogConnectionCartMapper;
37
    }
38
39
    /**
40
     * @param \Generated\Shared\Transfer\PunchoutCatalogConnectionTransfer $punchoutCatalogConnectionTransfer
41
     * @param \Orm\Zed\PunchoutCatalog\Persistence\PgwPunchoutCatalogConnection $punchoutCatalogConnectionEntity
42
     *
43
     * @return \Orm\Zed\PunchoutCatalog\Persistence\PgwPunchoutCatalogConnection
44
     */
45
    public function mapPunchoutCatalogConnectionTransferToEntity(
46
        PunchoutCatalogConnectionTransfer $punchoutCatalogConnectionTransfer,
47
        PgwPunchoutCatalogConnection $punchoutCatalogConnectionEntity
48
    ): PgwPunchoutCatalogConnection {
49
        $punchoutCatalogConnectionEntity->fromArray($punchoutCatalogConnectionTransfer->toArray());
50
51
        return $punchoutCatalogConnectionEntity;
52
    }
53
54
    /**
55
     * @param \Orm\Zed\PunchoutCatalog\Persistence\PgwPunchoutCatalogConnection $punchoutCatalogConnectionEntity
56
     * @param \Generated\Shared\Transfer\PunchoutCatalogConnectionTransfer $punchoutCatalogConnectionTransfer
57
     *
58
     * @return \Generated\Shared\Transfer\PunchoutCatalogConnectionTransfer
59
     */
60
    public function mapPunchoutCatalogConnectionEntityToTransfer(
61
        PgwPunchoutCatalogConnection $punchoutCatalogConnectionEntity,
62
        PunchoutCatalogConnectionTransfer $punchoutCatalogConnectionTransfer
63
    ): PunchoutCatalogConnectionTransfer {
64
        $punchoutCatalogConnectionTransfer->fromArray($punchoutCatalogConnectionEntity->toArray(), true);
65
66
        if ($punchoutCatalogConnectionEntity->getPgwPunchoutCatalogConnectionSetup()) {
67
            $punchoutCatalogConnectionTransfer->setSetup(
68
                $this->punchoutCatalogConnectionSetupMapper->mapPunchoutCatalogConnectionSetupEntityToTransfer(
69
                    $punchoutCatalogConnectionEntity->getPgwPunchoutCatalogConnectionSetup(),
70
                    new PunchoutCatalogConnectionSetupTransfer()
71
                )
72
            );
73
        }
74
75
        if ($punchoutCatalogConnectionEntity->getPgwPunchoutCatalogConnectionCart()) {
76
            $punchoutCatalogConnectionTransfer->setCart(
77
                $this->punchoutCatalogConnectionCartMapper->mapPunchoutCatalogConnectionCartEntityToTransfer(
78
                    $punchoutCatalogConnectionEntity->getPgwPunchoutCatalogConnectionCart(),
79
                    new PunchoutCatalogConnectionCartTransfer()
80
                )
81
            );
82
        }
83
84
        return $punchoutCatalogConnectionTransfer;
85
    }
86
87
    /**
88
     * @param \Orm\Zed\PunchoutCatalog\Persistence\PgwPunchoutCatalogTransaction $punchoutCatalogTransaction
89
     * @param \Generated\Shared\Transfer\PunchoutCatalogTransactionTransfer $punchoutCatalogTransactionTransfer
90
     *
91
     * @return \Generated\Shared\Transfer\PunchoutCatalogTransactionTransfer
92
     */
93
    public function mapPunchoutCatalogTransactionEntityToTransfer(
94
        PgwPunchoutCatalogTransaction $punchoutCatalogTransaction,
95
        PunchoutCatalogTransactionTransfer $punchoutCatalogTransactionTransfer
96
    ): PunchoutCatalogTransactionTransfer {
97
        $punchoutCatalogTransactionTransfer->fromArray($punchoutCatalogTransaction->toArray(), true);
98
99
        if ($punchoutCatalogTransaction->getPunchoutCatalogConnection()) {
100
            $punchoutCatalogTransactionTransfer->setConnection(
101
                $this->mapPunchoutCatalogConnectionEntityToTransfer(
102
                    $punchoutCatalogTransaction->getPunchoutCatalogConnection(),
103
                    new PunchoutCatalogConnectionTransfer()
104
                )
105
            );
106
        }
107
108
        return $punchoutCatalogTransactionTransfer;
109
    }
110
}
111