6
6
7
7
use Coduo \PHPMatcher \Value \SingleLineString ;
8
8
use Coduo \ToString \StringConverter ;
9
+ use function sprintf ;
10
+ use function implode ;
11
+ use function count ;
9
12
10
13
final class Backtrace
11
14
{
15
+ /**
16
+ * @var mixed[]
17
+ */
12
18
private $ trace ;
13
19
14
20
public function __construct ()
@@ -18,7 +24,7 @@ public function __construct()
18
24
19
25
public function matcherCanMatch (string $ name , $ value , bool $ result ) : void
20
26
{
21
- $ this ->trace [] = \ sprintf (
27
+ $ this ->trace [] = sprintf (
22
28
'#%d Matcher %s %s match pattern "%s" ' ,
23
29
$ this ->entriesCount (),
24
30
$ name ,
@@ -29,7 +35,7 @@ public function matcherCanMatch(string $name, $value, bool $result) : void
29
35
30
36
public function matcherEntrance (string $ name , $ value , $ pattern ) : void
31
37
{
32
- $ this ->trace [] = \ sprintf (
38
+ $ this ->trace [] = sprintf (
33
39
'#%d Matcher %s matching value "%s" with "%s" pattern ' ,
34
40
$ this ->entriesCount (),
35
41
$ name ,
@@ -40,7 +46,7 @@ public function matcherEntrance(string $name, $value, $pattern) : void
40
46
41
47
public function matcherSucceed (string $ name , $ value , $ pattern ) : void
42
48
{
43
- $ this ->trace [] = \ sprintf (
49
+ $ this ->trace [] = sprintf (
44
50
'#%d Matcher %s successfully matched value "%s" with "%s" pattern ' ,
45
51
$ this ->entriesCount (),
46
52
$ name ,
@@ -51,15 +57,15 @@ public function matcherSucceed(string $name, $value, $pattern) : void
51
57
52
58
public function matcherFailed (string $ name , $ value , $ pattern , string $ error ) : void
53
59
{
54
- $ this ->trace [] = \ sprintf (
60
+ $ this ->trace [] = sprintf (
55
61
'#%d Matcher %s failed to match value "%s" with "%s" pattern ' ,
56
62
$ this ->entriesCount (),
57
63
$ name ,
58
64
new SingleLineString ((string ) new StringConverter ($ value )),
59
65
new SingleLineString ((string ) new StringConverter ($ pattern ))
60
66
);
61
67
62
- $ this ->trace [] = \ sprintf (
68
+ $ this ->trace [] = sprintf (
63
69
'#%d Matcher %s error: %s ' ,
64
70
$ this ->entriesCount (),
65
71
$ name ,
@@ -69,7 +75,7 @@ public function matcherFailed(string $name, $value, $pattern, string $error) : v
69
75
70
76
public function expanderEntrance (string $ name , $ value ) : void
71
77
{
72
- $ this ->trace [] = \ sprintf (
78
+ $ this ->trace [] = sprintf (
73
79
'#%d Expander %s matching value "%s" ' ,
74
80
$ this ->entriesCount (),
75
81
$ name ,
@@ -79,7 +85,7 @@ public function expanderEntrance(string $name, $value) : void
79
85
80
86
public function expanderSucceed (string $ name , $ value ) : void
81
87
{
82
- $ this ->trace [] = \ sprintf (
88
+ $ this ->trace [] = sprintf (
83
89
'#%d Expander %s successfully matched value "%s" ' ,
84
90
$ this ->entriesCount (),
85
91
$ name ,
@@ -89,14 +95,14 @@ public function expanderSucceed(string $name, $value) : void
89
95
90
96
public function expanderFailed (string $ name , $ value , string $ error ) : void
91
97
{
92
- $ this ->trace [] = \ sprintf (
98
+ $ this ->trace [] = sprintf (
93
99
'#%d Expander %s failed to match value "%s" ' ,
94
100
$ this ->entriesCount (),
95
101
$ name ,
96
102
new SingleLineString ((string ) new StringConverter ($ value ))
97
103
);
98
104
99
- $ this ->trace [] = \ sprintf (
105
+ $ this ->trace [] = sprintf (
100
106
'#%d Expander %s error: %s ' ,
101
107
$ this ->entriesCount (),
102
108
$ name ,
@@ -106,12 +112,12 @@ public function expanderFailed(string $name, $value, string $error) : void
106
112
107
113
public function isEmpty () : bool
108
114
{
109
- return \ count ($ this ->trace ) === 0 ;
115
+ return count ($ this ->trace ) === 0 ;
110
116
}
111
117
112
118
public function __toString () : string
113
119
{
114
- return \ implode ("\n" , $ this ->trace );
120
+ return implode ("\n" , $ this ->trace );
115
121
}
116
122
117
123
public function raw () : array
@@ -121,6 +127,6 @@ public function raw() : array
121
127
122
128
private function entriesCount (): int
123
129
{
124
- return \ count ($ this ->trace ) + 1 ;
130
+ return count ($ this ->trace ) + 1 ;
125
131
}
126
132
}
0 commit comments