| 1 | <?php |
||
| 11 | abstract class AbstractFetcher implements FetcherInterface |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @return array |
||
| 15 | * @throws RuntimeException |
||
| 16 | */ |
||
| 17 | public function fetch() |
||
| 18 | { |
||
| 19 | //begin of business logic |
||
| 20 | $contentAsString = strip_tags($this->fetchContentAsStringOrThrowRuntimeException()); |
||
| 21 | $contentAsArray = explode(PHP_EOL, $contentAsString); |
||
| 22 | |||
| 23 | $lines = array_filter( |
||
| 24 | $contentAsArray, |
||
| 25 | function($item) { |
||
| 26 | return (strlen(trim($item)) > 0); |
||
| 27 | } |
||
| 28 | ); |
||
| 29 | |||
| 30 | return $lines; |
||
| 31 | //end of business logic |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return string |
||
| 36 | * @throws RuntimeException |
||
| 37 | */ |
||
| 38 | abstract protected function fetchContentAsStringOrThrowRuntimeException(); |
||
| 39 | } |
||
| 40 |