lithium\test\filter\Complexity::analyze PHP Method

analyze() public static method

Analyzes the results of a test run and returns the result of the analysis.
public static analyze ( object $report, array $options = [] ) : array
$report object The report instance running this filter and aggregating results
$options array Not used.
return array The results of the analysis.
    public static function analyze($report, array $options = array())
    {
        $filterResults = static::collect($report->results['filters'][__CLASS__]);
        $metrics = array('max' => array(), 'class' => array());
        foreach ($filterResults as $class => $methods) {
            if (!$methods) {
                continue;
            }
            $metrics['class'][$class] = array_sum($methods) / count($methods);
            foreach ($methods as $method => $count) {
                $metrics['max']["{$class}::{$method}()"] = $count;
            }
        }
        arsort($metrics['max']);
        arsort($metrics['class']);
        return $metrics;
    }

Usage Example

 /**
  * Tests the `analyze` method which compacts the test results and provides a convenient
  * summary of the complexity filter (class average and worst offenders).
  *
  * @see lithium\test\filter\Complexity::analyze()
  */
 public function testAnalyze()
 {
     extract($this->_paths);
     $group = new Group();
     $group->add($testClassTest);
     $this->report->group = $group;
     Complexity::apply($this->report, $group->tests());
     $results = Complexity::analyze($this->report);
     $expected = array('class' => array($testClass => 3));
     foreach ($this->_metrics as $method => $metric) {
         $expected['max'][$testClass . '::' . $method . '()'] = $metric;
     }
     $this->assertEqual($expected['max'], $results['max']);
     $this->assertEqual($expected['class'][$testClass], round($results['class'][$testClass]));
 }
All Usage Examples Of lithium\test\filter\Complexity::analyze