Extends
lithium\core\StaticObject
Helper method to get an array of `ReflectionMethod` or `ReflectionProperty` objects, wrapped
in a `Collection` object, and filtered based on a set of options.
Parameters
- ReflectionClass $class A reflection class instance from which to fetch.
- string $method A getter method to call on the `ReflectionClass` instance, which will return an array of items, i.e. `'getProperties'` or `'getMethods'`.
- array $options The options used to filter the resulting method list.
Returns
object Returns a `Collection` object instance containing the results of the items returned from the call to the method specified in `$method`, after being passed through the filters specified in `$options`.Source
protected static function _items($class, $method, $options) {
$defaults = array('names' => array(), 'self' => true, 'public' => true);
$options += $defaults;
$params = array(
'getProperties' => ReflectionProperty::IS_PUBLIC | (
$options['public'] ? 0 : ReflectionProperty::IS_PROTECTED
)
);
$data = isset($params[$method]) ? $class->{$method}($params[$method]) : $class->{$method}();
if (!empty($options['names'])) {
$data = array_filter($data, function($item) use ($options) {
return in_array($item->getName(), (array) $options['names']);
});
}
if ($options['self']) {
$data = array_filter($data, function($item) use ($class) {
return ($item->getDeclaringClass()->getName() == $class->getName());
});
}
if ($options['public']) {
$data = array_filter($data, function($item) { return $item->isPublic(); });
}
return static::_instance('collection', compact('data'));
}