Completed
Push — master ( 866870...6584d5 )
by Andrii
15:02
created

SimpleAction::isApplicable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
crap 6
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, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing\action;
12
13
use DateTime;
14
use hiqdev\php\billing\customer\CustomerInterface;
15
use hiqdev\php\billing\price\PriceInterface;
16
use hiqdev\php\billing\target\TargetInterface;
17
use hiqdev\php\billing\type\TypeInterface;
18
use hiqdev\php\units\QuantityInterface;
19
20
/**
21
 * Simple Action.
22
 * Charges only same target and same type.
23
 *
24
 * @author Andrii Vasyliev <[email protected]>
25
 */
26
class SimpleAction extends AbstractAction
27
{
28
    /**
29
     * @param mixed $id
0 ignored issues
show
Bug introduced by
There is no parameter named $id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
30
     * @param CustomerInterface $customer
31
     * @param TargetInterface $target
32
     * @param QuantityInterface $quantity
33
     * @param DateTime $time
34
     * @param TypeInterface $type
35
     */
36
    public function __construct(
37
        CustomerInterface $customer,
38
        TargetInterface $target,
39
        QuantityInterface $quantity,
40
        DateTime $time,
41
        TypeInterface $type
42
    ) {
43
        parent::__construct($customer, $target, $quantity, $time);
44
        $this->type = $type;
0 ignored issues
show
Bug introduced by
The property type does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
45
    }
46
47
    public function getType()
48
    {
49
        return $this->type;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function isApplicable(PriceInterface $price)
56
    {
57
        return $this->target->equals($price->getTarget()) &&
58
            $this->getType()->equals($price->getType());
59
    }
60
}
61