17
17
* @method bool hasNotice($record)
18
18
* @method bool hasInfo($record)
19
19
* @method bool hasDebug($record)
20
- *
21
20
* @method bool hasEmergencyRecords()
22
21
* @method bool hasAlertRecords()
23
22
* @method bool hasCriticalRecords()
26
25
* @method bool hasNoticeRecords()
27
26
* @method bool hasInfoRecords()
28
27
* @method bool hasDebugRecords()
29
- *
30
28
* @method bool hasEmergencyThatContains($message)
31
29
* @method bool hasAlertThatContains($message)
32
30
* @method bool hasCriticalThatContains($message)
35
33
* @method bool hasNoticeThatContains($message)
36
34
* @method bool hasInfoThatContains($message)
37
35
* @method bool hasDebugThatContains($message)
38
- *
39
36
* @method bool hasEmergencyThatMatches($message)
40
37
* @method bool hasAlertThatMatches($message)
41
38
* @method bool hasCriticalThatMatches($message)
44
41
* @method bool hasNoticeThatMatches($message)
45
42
* @method bool hasInfoThatMatches($message)
46
43
* @method bool hasDebugThatMatches($message)
47
- *
48
44
* @method bool hasEmergencyThatPasses($message)
49
45
* @method bool hasAlertThatPasses($message)
50
46
* @method bool hasCriticalThatPasses($message)
@@ -64,7 +60,7 @@ class TestLogger extends AbstractLogger
64
60
public $ recordsByLevel = [];
65
61
66
62
/**
67
- * @inheritdoc
63
+ * { @inheritdoc}
68
64
*/
69
65
public function log ($ level , $ message , array $ context = []): void
70
66
{
@@ -88,21 +84,23 @@ public function hasRecord($record, $level)
88
84
if (is_string ($ record )) {
89
85
$ record = ['message ' => $ record ];
90
86
}
87
+
91
88
return $ this ->hasRecordThatPasses (function ($ rec ) use ($ record ) {
92
89
if ($ rec ['message ' ] !== $ record ['message ' ]) {
93
90
return false ;
94
91
}
95
92
if (isset ($ record ['context ' ]) && $ rec ['context ' ] !== $ record ['context ' ]) {
96
93
return false ;
97
94
}
95
+
98
96
return true ;
99
97
}, $ level );
100
98
}
101
99
102
100
public function hasRecordThatContains ($ message , $ level )
103
101
{
104
102
return $ this ->hasRecordThatPasses (function ($ rec ) use ($ message ) {
105
- return strpos ($ rec ['message ' ], $ message ) !== false ;
103
+ return false !== strpos ($ rec ['message ' ], $ message );
106
104
}, $ level );
107
105
}
108
106
@@ -123,20 +121,22 @@ public function hasRecordThatPasses(callable $predicate, $level)
123
121
return true ;
124
122
}
125
123
}
124
+
126
125
return false ;
127
126
}
128
127
129
128
public function __call ($ method , $ args )
130
129
{
131
130
if (preg_match ('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/ ' , $ method , $ matches ) > 0 ) {
132
- $ genericMethod = $ matches [1 ] . ('Records ' !== $ matches [3 ] ? 'Record ' : '' ) . $ matches [3 ];
131
+ $ genericMethod = $ matches [1 ]. ('Records ' !== $ matches [3 ] ? 'Record ' : '' ). $ matches [3 ];
133
132
$ level = strtolower ($ matches [2 ]);
134
133
if (method_exists ($ this , $ genericMethod )) {
135
134
$ args [] = $ level ;
135
+
136
136
return call_user_func_array ([$ this , $ genericMethod ], $ args );
137
137
}
138
138
}
139
- throw new \BadMethodCallException ('Call to undefined method ' . get_class ($ this ) . ':: ' . $ method . '() ' );
139
+ throw new \BadMethodCallException ('Call to undefined method ' . get_class ($ this ). ':: ' . $ method. '() ' );
140
140
}
141
141
142
142
public function reset ()
0 commit comments