Passed
Branch feature/ECO-808-scrutinizer (bde35b)
by Andrey
07:45
created

AbstractByOrderConditionPlugin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Importance

Changes 0
Metric Value
dl 22
loc 22
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A check() 9 9 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * Apache OSL-2
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Amazonpay\Communication\Plugin\Oms\Condition;
9
10
use Orm\Zed\Sales\Persistence\SpySalesOrderItem;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\Sales\Persistence\SpySalesOrderItem 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\Oms\Dependency\Plugin\Condition\ConditionInterface;
12
13 View Code Duplication
abstract class AbstractByOrderConditionPlugin implements ConditionInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
16
    /**
17
     * @return array
18
     */
19
    abstract protected function getStatuses();
20
21
    /**
22
     * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem
23
     *
24
     * @return bool
25
     */
26
    public function check(SpySalesOrderItem $orderItem)
27
    {
28
        foreach ($orderItem->getOrder()->getItems() as $salesOrderItem) {
29
            if (in_array($salesOrderItem->getState()->getName(), $this->getStatuses(), true)) {
30
                return true;
31
            }
32
        }
33
34
        return false;
35
    }
36
37
}
38