| Conditions | 4 |
| Paths | 5 |
| Total Lines | 30 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public static function create(array $options = []): array |
||
| 11 | { |
||
| 12 | $options = static::mergeWithDefaultOptions($options); |
||
| 13 | |||
| 14 | if (empty($options['watch']['directories'])) { |
||
| 15 | throw new InvalidArgumentException( |
||
| 16 | 'The watch directories do not exist. Make sure you are running the watcher from '. |
||
| 17 | 'the root of your project, or create a custom config file.' |
||
| 18 | ); |
||
| 19 | } |
||
| 20 | |||
| 21 | $finder = (new Finder()) |
||
| 22 | ->ignoreDotFiles(false) |
||
| 23 | ->ignoreVCS(false) |
||
| 24 | ->name($options['watch']['fileMask']) |
||
| 25 | ->files() |
||
| 26 | ->in($options['watch']['directories']); |
||
| 27 | |||
| 28 | $watcher = (new Watcher($finder)); |
||
| 29 | |||
| 30 | if (isset($options['cache'])) { |
||
| 31 | $watcher->useCacheFile($options['cache']); |
||
| 32 | } |
||
| 33 | |||
| 34 | if (isset($options['phpunitArguments'])) { |
||
| 35 | $watcher->usePhpunitArguments($options['phpunitArguments']); |
||
| 36 | } |
||
| 37 | |||
| 38 | return [$watcher, $options]; |
||
| 39 | } |
||
| 40 | |||
| 66 |