Total Complexity | 6 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | final class Transaction implements \JsonSerializable |
||
9 | { |
||
10 | use TransactionName; |
||
11 | use TransactionType; |
||
12 | |||
13 | /** |
||
14 | * @param string $name |
||
15 | * @param string $type |
||
16 | */ |
||
17 | 5 | public function __construct($name, $type) |
|
18 | { |
||
19 | 5 | $this->assertName($name); |
|
20 | 4 | $this->assertType($type); |
|
21 | |||
22 | 3 | $this->name = (string) $name; |
|
23 | 3 | $this->type = (string) $type; |
|
24 | 3 | } |
|
25 | |||
26 | /** |
||
27 | * @param mixed $name |
||
28 | * |
||
29 | * @return void |
||
30 | */ |
||
31 | 5 | private function assertName($name) |
|
32 | { |
||
33 | 5 | if (false === is_string($name)) { |
|
34 | 1 | throw new \InvalidArgumentException('The [name] must be of type string.'); |
|
35 | } |
||
36 | 4 | } |
|
37 | |||
38 | /** |
||
39 | * @param mixed $type |
||
40 | * |
||
41 | * @return void |
||
42 | */ |
||
43 | 4 | private function assertType($type) |
|
47 | } |
||
48 | 3 | } |
|
49 | |||
50 | /** |
||
51 | * @return array |
||
52 | */ |
||
53 | 2 | public function jsonSerialize() |
|
58 | 2 | ]; |
|
59 | } |
||
61 |