Conditions | 2 |
Paths | 4 |
Total Lines | 29 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 2.0491 |
Changes | 0 |
1 | <?php |
||
47 | 1 | public function mock(string $job, array $params = []) |
|
48 | { |
||
49 | 1 | if (!array_key_exists($job, $this->mocks)) { |
|
50 | 1 | $this->mocks[$job] = []; |
|
51 | } |
||
52 | |||
53 | $mock = new class { |
||
54 | public $params; |
||
55 | public $result; |
||
56 | public function withParams($params) |
||
57 | { |
||
58 | $this->params = $params; |
||
59 | return $this; |
||
60 | } |
||
61 | 1 | public function willReturn($result) |
|
62 | { |
||
63 | 1 | $this->result = $result; |
|
64 | 1 | return $this; |
|
65 | } |
||
66 | }; |
||
67 | |||
68 | 1 | if (count($params)) { |
|
69 | 1 | $mock->params = $params; |
|
70 | } |
||
71 | |||
72 | 1 | $this->mocks[$job][] = $mock; |
|
73 | |||
74 | 1 | return $mock; |
|
75 | } |
||
76 | } |
||
77 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: