lithium\test\filter\Complexity::apply()

public static method

Takes an instance of an object (usually a Collection object) containing test instances. Introspects the test subject classes to extract cyclomatic complexity data.

Parameters

  • object $report

    Instance of Report which is calling apply.

  • \lithium\util\Collection $tests

    The tests to apply this filter on.

  • array $options

    Additional options to overwrite dependencies.

    • 'classes' array: Overwrite default classes array.

Returns

object

Returns the instance of $tests.

Source

	public static function apply($report, $tests, array $options = []) {
		$results = [];
		foreach ($tests->invoke('subject') as $class) {
			$results[$class] = [];

			if (!$methods = Inspector::methods($class, 'ranges', ['public' => false])) {
				continue;
			}
			foreach ($methods as $method => $lines) {
				$lines = Inspector::lines($class, $lines);
				$branches = Parser::tokenize(join("\n", (array) $lines), [
					'include' => static::$_include
				]);
				$results[$class][$method] = count($branches) + 1;
				$report->collect(__CLASS__, $results);
			}
		}
		return $tests;
	}