89% of 89OPs |
100% of 17Lines |
77% of 13Branches |
80% of 10Paths |
| Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
|---|---|---|---|---|---|---|---|---|
| mageekguy\atoum\writer::__construct() | 10 | 100% | 2 | 100% | 1 | 0% | 1 | 100% |
| mageekguy\atoum\writer::setAdapter() | 16 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
| mageekguy\atoum\writer::getAdapter() | 6 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
| mageekguy\atoum\writer::reset() | 5 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
| mageekguy\atoum\writer::addDecorator() | 10 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
| mageekguy\atoum\writer::getDecorators() | 6 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
| mageekguy\atoum\writer::removeDecorators() | 9 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
| mageekguy\atoum\writer::write() | 27 | 63% | 5 | 100% | 6 | 67% | 3 | 33% |
| # | |
|---|---|
| 1 |
<?php |
| 2 |
|
| 3 |
namespace mageekguy\atoum; |
| 4 |
|
| 5 |
use |
| 6 |
mageekguy\atoum\writer\decorator |
| 7 |
; |
| 8 |
|
| 9 |
abstract class writer |
| 10 |
{
|
| 11 |
protected $adapter = null; |
| 12 |
protected $decorators = array(); |
| 13 |
|
| 14 |
public function __construct(adapter $adapter = null)100% |
| 15 |
{
|
| 16 |
$this->setAdapter($adapter); |
| 17 |
} |
| 18 |
|
| 19 |
public function setAdapter(adapter $adapter = null)100% |
| 20 |
{
|
| 21 |
$this->adapter = $adapter ?: new adapter(); |
| 22 |
|
| 23 |
return $this; |
| 24 |
} |
| 25 |
|
| 26 |
public function getAdapter()100% |
| 27 |
{
|
| 28 |
return $this->adapter; |
| 29 |
} |
| 30 |
|
| 31 |
public function reset()100% |
| 32 |
{
|
| 33 |
return $this; |
| 34 |
} |
| 35 |
|
| 36 |
public function addDecorator(decorator $decorator)100% |
| 37 |
{
|
| 38 |
$this->decorators[] = $decorator; |
| 39 |
|
| 40 |
return $this; |
| 41 |
} |
| 42 |
|
| 43 |
public function getDecorators()100% |
| 44 |
{
|
| 45 |
return $this->decorators; |
| 46 |
} |
| 47 |
|
| 48 |
public function removeDecorators()100% |
| 49 |
{
|
| 50 |
$this->decorators = array(); |
| 51 |
|
| 52 |
return $this; |
| 53 |
} |
| 54 |
|
| 55 |
public function write($string)100% |
| 56 |
{
|
| 57 |
foreach ($this->decorators as $decorator) |
| 58 |
{
|
| 59 |
$string = $decorator->decorate($string); |
| 60 |
} |
| 61 |
|
| 62 |
$this->doWrite($string); |
| 63 |
|
| 64 |
return $this; |
| 65 |
} |
| 66 |
|
| 67 |
public abstract function clear(); |
| 68 |
|
| 69 |
protected abstract function doWrite($string); |
| 70 |
} |