ProductExpander   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A expandItems() 0 17 5
A __construct() 0 3 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\Ratepay\Business\Expander;
9
10
use Generated\Shared\Transfer\CartChangeTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\CartChangeTransfer 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 SprykerEco\Zed\Ratepay\Dependency\Facade\RatepayToProductInterface;
12
13
class ProductExpander implements ProductExpanderInterface
14
{
15
    /**
16
     * @var \SprykerEco\Zed\Ratepay\Dependency\Facade\RatepayToProductBridge
17
     */
18
    protected $ratepayToProductBridge;
19
20
    /**
21
     * @param \SprykerEco\Zed\Ratepay\Dependency\Facade\RatepayToProductInterface $ratepayToProductBridge
22
     */
23
    public function __construct(RatepayToProductInterface $ratepayToProductBridge)
24
    {
25
        $this->ratepayToProductBridge = $ratepayToProductBridge;
0 ignored issues
show
Documentation Bug introduced by
$ratepayToProductBridge is of type SprykerEco\Zed\Ratepay\D...tepayToProductInterface, but the property $ratepayToProductBridge was declared to be of type SprykerEco\Zed\Ratepay\D...\RatepayToProductBridge. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
26
    }
27
28
    /**
29
     * @param \Generated\Shared\Transfer\CartChangeTransfer $change
30
     *
31
     * @return \Generated\Shared\Transfer\CartChangeTransfer
32
     */
33
    public function expandItems(CartChangeTransfer $change)
34
    {
35
        foreach ($change->getItems() as $cartItem) {
36
            $productConcreteTransfer = $this->ratepayToProductBridge->getProductConcrete($cartItem->getSku());
37
38
            foreach ($productConcreteTransfer->getLocalizedAttributes() as $localizedAttribute) {
39
                $attr = $localizedAttribute->getAttributes();
40
                if (isset($attr['short_description'])) {
41
                    $cartItem->setDescriptionAddition($attr['short_description']);
42
                }
43
                if (isset($attr['long_description'])) {
44
                    $cartItem->setDescription($attr['long_description']);
45
                }
46
            }
47
        }
48
49
        return $change;
50
    }
51
}
52