Total Complexity | 3 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Coverage | 81.82% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | trait ReadsModel |
||
14 | { |
||
15 | /** |
||
16 | * Lazily read the model line by line. |
||
17 | * |
||
18 | * @param string $model |
||
19 | * @return iterable |
||
20 | */ |
||
21 | 1 | protected function readModel(string $model): iterable |
|
22 | { |
||
23 | 1 | $filename = (new ReflectionClass($model))->getFileName(); |
|
24 | 1 | $handle = fopen($filename, 'rb'); |
|
25 | |||
26 | 1 | while (($line = fgets($handle, 1024)) !== false) { |
|
27 | 1 | yield $line; |
|
28 | } |
||
29 | |||
30 | fclose($handle); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Lazily read the first line of the given model method |
||
35 | * |
||
36 | * @param ReflectionMethod $method |
||
37 | * @return string |
||
38 | */ |
||
39 | 1 | protected function readFirstLineOfMethod(ReflectionMethod $method): string |
|
46 | } |
||
47 | } |
||
48 |