Conditions | 4 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | 5 | public function find($pattern, \SplFileInfo $fileInfo) |
|
25 | { |
||
26 | 5 | if (!is_string($pattern)) { |
|
27 | 1 | throw new \InvalidArgumentException('Pattern should be an string'); |
|
28 | } |
||
29 | 4 | $pattern = $this->createRegExp($pattern); |
|
30 | 4 | $data = fopen($fileInfo->getPathName(), 'r'); |
|
31 | |||
32 | 4 | $return = false; |
|
33 | |||
34 | 4 | while ($line = fgets($data, 1024)) { |
|
35 | 4 | if (preg_match($pattern, $line)) { |
|
36 | 3 | $return = $fileInfo; |
|
37 | 3 | } |
|
38 | 4 | } |
|
39 | |||
40 | 4 | return $return; |
|
41 | } |
||
42 | |||
57 |