Passed
Push — master ( c5d222...d7a54d )
by Dmitry
04:02
created

LeasingWasFinished::getCharge()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace hiqdev\php\billing\charge\modifiers\event;
4
5
use hiqdev\php\billing\charge\ChargeInterface;
6
use League\Event\AbstractEvent;
0 ignored issues
show
Bug introduced by SilverFire - Dmitry Naumenko
The type League\Event\AbstractEvent 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...
7
8
class LeasingWasFinished extends AbstractEvent implements \JsonSerializable
9
{
10
    /**
11
     * @var ChargeInterface
12
     */
13
    private $charge;
14
    /**
15
     * @var \DateTimeImmutable
16
     */
17
    private $time;
18
19
    private function __construct(ChargeInterface $charge, \DateTimeImmutable $time)
20
    {
21
        $this->charge = $charge;
22
        $this->time = $time;
23
    }
24
25
    public static function onCharge(ChargeInterface $charge, \DateTimeImmutable $time): self
26
    {
27
        return new self($charge, $time);
28
    }
29
30
    /**
31
     * @return ChargeInterface
32
     */
33
    public function getCharge(): ChargeInterface
34
    {
35
        return $this->charge;
36
    }
37
38
    /**
39
     * @return \DateTimeImmutable
40
     */
41
    public function getTime(): \DateTimeImmutable
42
    {
43
        return $this->time;
44
    }
45
46
    /**
47
     * Specify data which should be serialized to JSON
48
     *
49
     * @link https://php.net/manual/en/jsonserializable.jsonserialize.php
50
     * @return mixed data which can be serialized by <b>json_encode</b>,
51
     * which is a value of any type other than a resource.
52
     * @since 5.4.0
53
     */
54
    public function jsonSerialize()
55
    {
56
        return [
57
            'price_id' => $this->charge->getPrice()->getId(),
0 ignored issues
show
Bug introduced by SilverFire - Dmitry Naumenko
The method getId() does not exist on hiqdev\php\billing\price\PriceInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to hiqdev\php\billing\price\PriceInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
            'price_id' => $this->charge->getPrice()->/** @scrutinizer ignore-call */ getId(),
Loading history...
58
            'part_id' => $this->charge->getPrice()->getTarget()->getId(),
59
        ];
60
    }
61
}
62