99% of 68OPs |
100% of 11Lines |
92% of 12Branches |
100% of 5Paths |
| Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
|---|---|---|---|---|---|---|---|---|
| mageekguy\atoum\readers\std\in::read() | 32 | 100% | 2 | 100% | 5 | 100% | 2 | 100% |
| mageekguy\atoum\readers\std\in::init() | 36 | 97% | 9 | 100% | 7 | 86% | 3 | 100% |
| # | |
|---|---|
| 1 |
<?php |
| 2 |
|
| 3 |
namespace mageekguy\atoum\readers\std; |
| 4 |
|
| 5 |
use |
| 6 |
mageekguy\atoum\reader, |
| 7 |
mageekguy\atoum\exceptions |
| 8 |
; |
| 9 |
|
| 10 |
class in extends reader |
| 11 |
{
|
| 12 |
protected $resource = null; |
| 13 |
|
| 14 |
public function read($length = null)100% |
| 15 |
{
|
| 16 |
$this->init(); |
| 17 |
|
| 18 |
// fgets() must be called without any second argument if $length is null to avoid message "Warning: fgets(): Length parameter must be greater than 0" |
| 19 |
return ($length === null ? $this->adapter->fgets($this->resource) : $this->adapter->fgets($this->resource, $length)); |
| 20 |
} |
| 21 |
|
| 22 |
protected function init()100% |
| 23 |
{
|
| 24 |
if ($this->resource === null) |
| 25 |
{
|
| 26 |
$resource = $this->adapter->fopen('php://stdin', 'r');
|
| 27 |
|
| 28 |
if ($resource === false) |
| 29 |
{
|
| 30 |
throw new exceptions\runtime('Unable to open php://stdin stream');
|
| 31 |
} |
| 32 |
|
| 33 |
$this->resource = $resource; |
| 34 |
} |
| 35 |
|
| 36 |
return $this; |
| 37 |
} |
| 38 |
} |