| Conditions | 6 |
| Paths | 9 |
| Total Lines | 21 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 6.105 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 38 | 59 | protected function file() |
|
| 39 | { |
||
| 40 | 59 | if (!$this->handle) { |
|
| 41 | 59 | $exception = null; |
|
| 42 | try { |
||
| 43 | 59 | $handle = fopen($this->filename, 'r'); |
|
| 44 | 58 | if ($handle === false) { |
|
| 45 | $error = error_get_last(); |
||
| 46 | throw new \RuntimeException($error ? $error['message'] : 'fopen error'); |
||
| 47 | } |
||
| 48 | 58 | $this->handle = $handle; |
|
| 49 | 1 | } catch (Throwable $e) { |
|
| 50 | 1 | $this->handle = null; |
|
| 51 | 1 | $exception = $e; |
|
| 52 | } |
||
| 53 | 59 | if (!$this->handle) { |
|
| 54 | 1 | throw new SourceException("Could not open file '{$this->filename}'", 0, $exception); |
|
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | 58 | return $this->handle; |
|
| 59 | } |
||
| 85 |