100% of 155OPs |
100% of 31Lines |
92% of 12Branches |
100% of 9Paths |
Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
---|---|---|---|---|---|---|---|---|
mageekguy\atoum\report\fields\test\memory\cli::__construct() | 22 | 100% | 6 | 100% | 1 | 0% | 1 | 100% |
mageekguy\atoum\report\fields\test\memory\cli::__toString() | 67 | 100% | 16 | 100% | 5 | 100% | 2 | 100% |
mageekguy\atoum\report\fields\test\memory\cli::setPrompt() | 16 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\report\fields\test\memory\cli::getPrompt() | 6 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\report\fields\test\memory\cli::setTitleColorizer() | 16 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\report\fields\test\memory\cli::getTitleColorizer() | 6 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\report\fields\test\memory\cli::setMemoryColorizer() | 16 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\report\fields\test\memory\cli::getMemoryColorizer() | 6 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
# | |
---|---|
1 |
<?php |
2 |
|
3 |
namespace mageekguy\atoum\report\fields\test\memory; |
4 |
|
5 |
use |
6 |
mageekguy\atoum, |
7 |
mageekguy\atoum\locale, |
8 |
mageekguy\atoum\cli\prompt, |
9 |
mageekguy\atoum\cli\colorizer, |
10 |
mageekguy\atoum\report |
11 |
; |
12 |
|
13 |
class cli extends report\fields\test\memory |
14 |
{ |
15 |
protected $prompt = null; |
16 |
protected $titleColorizer = null; |
17 |
protected $memoryColorizer = null; |
18 |
|
19 |
public function __construct()100% |
20 |
{ |
21 |
parent::__construct(); |
22 |
|
23 |
$this |
24 |
->setPrompt() |
25 |
->setTitleColorizer() |
26 |
->setMemoryColorizer() |
27 |
; |
28 |
} |
29 |
|
30 |
public function __toString()100% |
31 |
{ |
32 |
return $this->prompt . |
33 |
sprintf( |
34 |
$this->locale->_('%1$s: %2$s.'), |
35 |
$this->titleColorizer->colorize($this->locale->_('Memory usage')), |
36 |
$this->memoryColorizer->colorize( |
37 |
$this->value === null |
38 |
? |
39 |
$this->locale->_('unknown') |
40 |
: |
41 |
sprintf( |
42 |
$this->locale->_('%4.2f Mb'), |
43 |
$this->value / 1048576 |
44 |
) |
45 |
) |
46 |
) . |
47 |
PHP_EOL |
48 |
; |
49 |
} |
50 |
|
51 |
public function setPrompt(prompt $prompt = null)100% |
52 |
{ |
53 |
$this->prompt = $prompt ?: new prompt(); |
54 |
|
55 |
return $this; |
56 |
} |
57 |
|
58 |
public function getPrompt()100% |
59 |
{ |
60 |
return $this->prompt; |
61 |
} |
62 |
|
63 |
public function setTitleColorizer(colorizer $colorizer = null)100% |
64 |
{ |
65 |
$this->titleColorizer = $colorizer ?: new colorizer(); |
66 |
|
67 |
return $this; |
68 |
} |
69 |
|
70 |
public function getTitleColorizer()100% |
71 |
{ |
72 |
return $this->titleColorizer; |
73 |
} |
74 |
|
75 |
public function setMemoryColorizer(colorizer $colorizer = null)100% |
76 |
{ |
77 |
$this->memoryColorizer = $colorizer ?: new colorizer(); |
78 |
|
79 |
return $this; |
80 |
} |
81 |
|
82 |
public function getMemoryColorizer()100% |
83 |
{ |
84 |
return $this->memoryColorizer; |
85 |
} |
86 |
} |