| Conditions | 5 |
| Paths | 5 |
| Total Lines | 21 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function __invoke() |
||
| 31 | { |
||
| 32 | $files = glob($this->globExpression, GLOB_MARK); |
||
| 33 | $files = array_filter($files, function ($fileName) { |
||
| 34 | return strrpos($fileName, DIRECTORY_SEPARATOR) !== \strlen($fileName) - 1; |
||
| 35 | }); |
||
| 36 | foreach ($files as $file) { |
||
| 37 | // Note: length = 0 for Blob types (unlimited) but not for Binary types (limited in length) |
||
| 38 | if ($this->column->getLength() !== 0 && \filesize($file) > $this->column->getLength()) { |
||
| 39 | throw FileTooLargeException::create($file, $this->column); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | if (\count($files) === 0) { |
||
| 43 | throw new NoTestFilesFoundException("No files found for glob expression '".$this->globExpression."'"); |
||
| 44 | } |
||
| 45 | $files = array_values($files); |
||
| 46 | $chosenFile = $files[random_int(0, \count($files) - 1)]; |
||
| 47 | |||
| 48 | // TODO: throw exception if column not large enough |
||
| 49 | |||
| 50 | return fopen($chosenFile, 'rb'); |
||
| 51 | } |
||
| 53 |