Completed
Push — master ( a7e110...90712e )
by Andrii
02:38
created

SimpleAction::isApplicable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
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 ClientInterface $client
26
     * @param TargetInterface $target
27
     * @param QuantityInterface $quantity
28
     * @param DateTime $time
29
     * @param TypeInterface $type
30
     */
31 2
    public function __construct(
32
        ClientInterface $client,
33
        TargetInterface $target,
34
        QuantityInterface $quantity,
35
        DateTime $time,
36
        TypeInterface $type
37
    ) {
38 2
        parent::__construct($client, $target, $quantity, $time);
39 2
        $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...
40 2
    }
41
42 2
    public function getType()
43
    {
44 2
        return $this->type;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 2
    public function isApplicable(PriceInterface $price)
51
    {
52 2
        return $this->target->equals($price->getTarget()) &&
53 2
            $this->getType()->equals($price->getType());
54
    }
55
}
56