Completed
Push — master ( a88c1a...2a7402 )
by Andrii
02:44
created

SimpleCalculator::getGeneralizer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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\support\order;
12
13
use hiqdev\php\billing\charge\Generalizer;
14
use hiqdev\php\billing\charge\GeneralizerInterface;
15
use hiqdev\php\billing\order\Calculator;
16
use hiqdev\php\billing\plan\PlanInterface;
17
use hiqdev\php\billing\sale\SaleInterface;
18
use hiqdev\php\billing\tests\support\plan\SimplePlanRepository;
19
use hiqdev\php\billing\tests\support\sale\SimpleSaleRepository;
20
21
class SimpleCalculator extends Calculator
22
{
23
    /**
24
     * @param GeneralizerInterface $generalizer
25
     * @param SaleRepositoryInterface|SaleInterface $sale
0 ignored issues
show
Bug introduced by
The type hiqdev\php\billing\tests...SaleRepositoryInterface 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...
26
     * @param PlanRepositoryInterface|PlanInterface $plan
0 ignored issues
show
Bug introduced by
The type hiqdev\php\billing\tests...PlanRepositoryInterface 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...
27
     */
28
    public function __construct(GeneralizerInterface $generalizer = null, $sale = null, $plan = null)
29
    {
30
        $this->generalizer = $generalizer ?: new Generalizer();
31
        if ($sale instanceof SaleInterface) {
32
            if (empty($plan)) {
33
                $plan = $sale->getPlan();
34
            }
35
            $sale = new SimpleSaleRepository($sale);
36
        }
37
        if ($plan instanceof PlanInterface) {
38
            $plan = new SimplePlanRepository($plan);
39
        }
40
41
        return parent::__construct($this->generalizer, $sale, $plan);
0 ignored issues
show
Bug introduced by
Are you sure the usage of parent::__construct($thi...eralizer, $sale, $plan) targeting hiqdev\php\billing\order\Calculator::__construct() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
42
    }
43
44
    public function getGeneralizer(): GeneralizerInterface
45
    {
46
        return $this->generalizer;
47
    }
48
}
49