79% of 312OPs |
100% of 49Lines |
77% of 30Branches |
75% of 20Paths |
# | |
---|---|
1 |
<?php |
2 |
|
3 |
namespace mageekguy\atoum\report\fields\runner\outputs; |
4 |
|
5 |
use |
6 |
mageekguy\atoum, |
7 |
mageekguy\atoum\locale, |
8 |
mageekguy\atoum\cli\prompt, |
9 |
mageekguy\atoum\cli\colorizer, |
10 |
mageekguy\atoum\report\fields\runner\outputs |
11 |
; |
12 |
|
13 |
class cli extends outputs |
14 |
{ |
15 |
protected $titlePrompt = null; |
16 |
protected $titleColorizer = null; |
17 |
protected $methodPrompt = null; |
18 |
protected $methodColorizer = null; |
19 |
protected $outputPrompt = null; |
20 |
protected $outputColorizer = null; |
21 |
|
22 |
public function __construct()100% |
23 |
{ |
24 |
parent::__construct(); |
25 |
|
26 |
$this |
27 |
->setTitlePrompt() |
28 |
->setTitleColorizer() |
29 |
->setMethodPrompt() |
30 |
->setMethodColorizer() |
31 |
->setOutputPrompt() |
32 |
->setOutputColorizer() |
33 |
; |
34 |
} |
35 |
|
36 |
public function __toString()100% |
37 |
{ |
38 |
$string = ''; |
39 |
|
40 |
if ($this->runner !== null) |
41 |
{ |
42 |
$outputs = $this->runner->getScore()->getOutputs(); |
43 |
|
44 |
$sizeOfOutputs = sizeof($outputs); |
45 |
|
46 |
if ($sizeOfOutputs > 0) |
47 |
{ |
48 |
$string .= |
49 |
$this->titlePrompt . |
50 |
sprintf( |
51 |
$this->locale->_('%s:'), |
52 |
$this->titleColorizer->colorize(sprintf($this->locale->__('There is %d output', 'There are %d outputs', $sizeOfOutputs), $sizeOfOutputs)) |
53 |
) . |
54 |
PHP_EOL |
55 |
; |
56 |
|
57 |
foreach ($outputs as $output) |
58 |
{ |
59 |
$string .= $this->methodPrompt . sprintf('%s:', $this->methodColorizer->colorize(sprintf($this->locale->_('In %s::%s()'), $output['class'], $output['method']))) . PHP_EOL; |
60 |
|
61 |
foreach (explode(PHP_EOL, rtrim($output['value'])) as $line) |
62 |
{ |
63 |
$string .= $this->outputPrompt . $this->outputColorizer->colorize($line) . PHP_EOL; |
64 |
} |
65 |
} |
66 |
} |
67 |
} |
68 |
|
69 |
return $string; |
70 |
} |
71 |
|
72 |
public function setTitlePrompt(prompt $prompt = null)100% |
73 |
{ |
74 |
$this->titlePrompt = $prompt ?: new prompt(); |
75 |
|
76 |
return $this; |
77 |
} |
78 |
|
79 |
public function getTitlePrompt()100% |
80 |
{ |
81 |
return $this->titlePrompt; |
82 |
} |
83 |
|
84 |
public function setTitleColorizer(colorizer $colorizer = null)100% |
85 |
{ |
86 |
$this->titleColorizer = $colorizer ?: new colorizer(); |
87 |
|
88 |
return $this; |
89 |
} |
90 |
|
91 |
public function getTitleColorizer()100% |
92 |
{ |
93 |
return $this->titleColorizer; |
94 |
} |
95 |
|
96 |
public function setMethodPrompt(prompt $prompt = null)100% |
97 |
{ |
98 |
$this->methodPrompt = $prompt ?: new prompt(); |
99 |
|
100 |
return $this; |
101 |
} |
102 |
|
103 |
public function getMethodPrompt()100% |
104 |
{ |
105 |
return $this->methodPrompt; |
106 |
} |
107 |
|
108 |
public function setMethodColorizer(colorizer $colorizer = null)100% |
109 |
{ |
110 |
$this->methodColorizer = $colorizer ?: new colorizer(); |
111 |
|
112 |
return $this; |
113 |
} |
114 |
|
115 |
public function getMethodColorizer()100% |
116 |
{ |
117 |
return $this->methodColorizer; |
118 |
} |
119 |
|
120 |
public function setOutputPrompt(prompt $prompt = null)100% |
121 |
{ |
122 |
$this->outputPrompt = $prompt ?: new prompt(); |
123 |
|
124 |
return $this; |
125 |
} |
126 |
|
127 |
public function getOutputPrompt()100% |
128 |
{ |
129 |
return $this->outputPrompt; |
130 |
} |
131 |
|
132 |
public function setOutputColorizer(colorizer $colorizer = null)100% |
133 |
{ |
134 |
$this->outputColorizer = $colorizer ?: new colorizer(); |
135 |
|
136 |
return $this; |
137 |
} |
138 |
|
139 |
public function getOutputColorizer()100% |
140 |
{ |
141 |
return $this->outputColorizer; |
142 |
} |
143 |
} |