Total Complexity | 8 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Coverage | 45% |
Changes | 0 |
1 | <?php |
||
19 | class Order implements OrderInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var int|string|null |
||
23 | */ |
||
24 | protected $id; |
||
25 | |||
26 | /** |
||
27 | * @var CustomerInterface |
||
28 | */ |
||
29 | protected $customer; |
||
30 | |||
31 | /** |
||
32 | * @var ActionInterface[] array: actionKey => action |
||
33 | */ |
||
34 | protected $actions = []; |
||
35 | |||
36 | 2 | public function __construct($id, CustomerInterface $customer, array $actions = []) |
|
41 | 2 | } |
|
42 | |||
43 | public static function fromAction(ActionInterface $action) |
||
44 | { |
||
45 | return new static(null, $action->getCustomer(), [$action]); |
||
46 | } |
||
47 | |||
48 | public static function fromActions(array $actions) |
||
49 | { |
||
50 | $action = reset($actions); |
||
51 | if (!$action instanceof ActionInterface) { |
||
52 | throw new \Exception('wrong actions given in ' . __METHOD__); |
||
53 | } |
||
54 | |||
55 | return new static(null, $action->getCustomer(), $actions); |
||
56 | } |
||
57 | |||
58 | public function getId() |
||
59 | { |
||
60 | return $this->id; |
||
61 | } |
||
62 | |||
63 | 2 | public function getCustomer() |
|
64 | { |
||
65 | 2 | return $this->customer; |
|
66 | } |
||
67 | |||
68 | /** |
||
69 | * Returns actions. |
||
70 | * @return ActionInterface[] array: actionKey => action |
||
71 | */ |
||
72 | 2 | public function getActions() |
|
73 | { |
||
74 | 2 | return $this->actions; |
|
|
|||
75 | } |
||
76 | |||
77 | public function jsonSerialize() |
||
80 | } |
||
81 | } |
||
82 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: