Completed
Push — master ( 41f74f...866870 )
by Andrii
03:39
created

SimpleAction::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
ccs 0
cts 10
cp 0
rs 9.4285
cc 1
eloc 8
nc 1
nop 5
crap 2
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;
12
13
use DateTime;
14
use hiqdev\php\units\QuantityInterface;
15
16
/**
17
 * Simple Action.
18
 * Charges only same target and same type.
19
 *
20
 * @author Andrii Vasyliev <[email protected]>
21
 */
22
class SimpleAction extends AbstractAction
23
{
24
    /**
25
     * @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...
26
     * @param CustomerInterface $customer
27
     * @param TargetInterface $target
28
     * @param QuantityInterface $quantity
29
     * @param DateTime $time
30
     * @param TypeInterface $type
31
     */
32
    public function __construct(
33
        CustomerInterface $customer,
34
        TargetInterface $target,
35
        QuantityInterface $quantity,
36
        DateTime $time,
37
        TypeInterface $type
38
    ) {
39
        parent::__construct($customer, $target, $quantity, $time);
40
        $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...
41
    }
42
43
    public function getType()
44
    {
45
        return $this->type;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function isApplicable(PriceInterface $price)
52
    {
53
        return $this->target->equals($price->getTarget()) &&
54
            $this->getType()->equals($price->getType());
55
    }
56
}
57