Completed
Push — master ( 8530e7...2147ca )
by Andrii
02:54
created

SimpleSaleRepository   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 29
loc 29
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A findByAction() 4 4 1
A findByOrder() 9 9 2
A findByIds() 4 4 1

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
 * PHP Billing Library
4
 *
5
 * @link      https://github.com/hiqdev/php-billing
6
 * @package   php-billing
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing\tests\unit\sale;
12
13
use hiqdev\php\billing\action\ActionInterface;
14
use hiqdev\php\billing\order\OrderInterface;
15
use hiqdev\php\billing\sale\SaleInterface;
16
use hiqdev\php\billing\sale\SaleRepositoryInterface;
17
18 View Code Duplication
class SimpleSaleRepository implements SaleRepositoryInterface
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...
19
{
20
    protected $sale;
21
22
    public function __construct(SaleInterface $sale)
23
    {
24
        $this->sale = $sale;
25
    }
26
27
    public function findByAction(ActionInterface $action)
0 ignored issues
show
Unused Code introduced by
The parameter $action is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
    {
29
        return $this->sale;
30
    }
31
32
    public function findByOrder(OrderInterface $order)
33
    {
34
        $sales = [];
35
        foreach ($order->getActions() as $actionKey => $action) {
36
            $sales[$actionKey] = $this->findByAction($action);
37
        }
38
39
        return $sales;
40
    }
41
42
    public function findByIds(array $ids)
0 ignored issues
show
Unused Code introduced by
The parameter $ids is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
    {
44
        throw new \Exception('not implemented');
45
    }
46
}
47