Example #1
0
 /**
  * The Constructor.
  *
  * @param array $config Possible options values are:
  *                    - `'driver'` _object_: the driver instance which will log the coverage data.
  *                    - `'path'`   _array_ : the path(s) which contain the code source files.
  *                    - `'base'`   _string_: the base path of the repo (default: `getcwd`).
  *                    - `'prefix'` _string_: some prefix to remove to get the real file path.
  */
 public function __construct($config = [])
 {
     $defaults = ['driver' => null, 'path' => [], 'include' => '*.php', 'exclude' => [], 'type' => 'file', 'skipDots' => true, 'leavesOnly' => false, 'followSymlinks' => true, 'recursive' => true, 'base' => str_replace(DIRECTORY_SEPARATOR, '/', getcwd())];
     $config += $defaults;
     if (Interceptor::instance()) {
         $config += ['prefix' => rtrim(Interceptor::instance()->cachePath(), DS)];
     } else {
         $config += ['prefix' => ''];
     }
     $this->_driver = $config['driver'];
     $this->_paths = (array) $config['path'];
     $this->_base = $config['base'];
     $this->_prefix = $config['prefix'];
     $files = Dir::scan($this->_paths, $config);
     foreach ($files as $file) {
         $this->_coverage[realpath($file)] = [];
     }
 }
Example #2
0
 /**
  * The default `'load'` filter.
  */
 protected function _load()
 {
     return Filter::on($this, 'load', [], function ($chain) {
         $files = Dir::scan($this->args()->get('spec'), ['include' => $this->args()->get('pattern'), 'type' => 'file']);
         foreach ($files as $file) {
             require $file;
         }
     });
 }