public static function apply($report, $tests, array $options = array()) { $rules = new Rules(); $file = Libraries::get('li3_quality', 'path') . '/config/syntax.json'; $config = json_decode(file_get_contents($file), true) + array('name' => null, 'rules' => array(), 'options' => array()); foreach ($config['rules'] as $ruleName) { $class = Libraries::locate('rules.syntax', $ruleName); $rules->add(new $class()); } if ($config['options']) { $rules->options($config['options']); } foreach ($tests->invoke('subject') as $class) { $report->collect(__CLASS__, array($class => $rules->apply(new Testable(array('path' => Libraries::path($class)))))); } return $tests; }
/** * Loads rules configuration. * * @return object */ protected function _rules() { $rules = new Rules(); $files = array($this->config, Libraries::get('li3_quality', 'path') . '/config/syntax.json'); foreach ($files as $file) { if (file_exists($file)) { $this->out("Loading configuration file `{$file}`..."); $config = json_decode(file_get_contents($file), true) + array('name' => null, 'rules' => array(), 'options' => array()); break; } } foreach ($config['rules'] as $ruleName) { $class = Libraries::locate('rules.syntax', $ruleName); $rules->add(new $class()); } if ($config['options']) { $rules->options($config['options']); } return $rules; }