lithium\test\filter\Affected::_affected()

protected static method

Returns all classes directly depending on a given class.

Parameters

  • string $dependency

    The class name to use as a dependency.

  • string $exclude

    Regex path exclusion filter.

Returns

array

Classes having a direct dependency on $dependency. May contain duplicates.

Source

	protected static function _affected($dependency, $exclude = null) {
		$exclude = $exclude ?: '/(tests|webroot|resources|libraries|plugins)/';
		$classes = Libraries::find(true, compact('exclude') + ['recursive' => true]);
		$dependency = ltrim($dependency, '\\');
		$affected = [];

		foreach ($classes as $class) {
			if (isset(static::$_cachedDepends[$class])) {
				$depends = static::$_cachedDepends[$class];
			} else {
				$depends = Inspector::dependencies($class);
				$depends = array_map(function($c) { return ltrim($c, '\\'); }, $depends);
				static::$_cachedDepends[$class] = $depends;
			}

			if (in_array($dependency, $depends)) {
				$affected[] = $class;
			}
		}
		return $affected;
	}