TASK: Refactor code
* Reduce indentation. * Provide internal API to add new feature with necessary checks.
This commit is contained in:
parent
7f7a7aa38d
commit
370015e7c0
1 changed files with 19 additions and 7 deletions
|
@ -47,16 +47,28 @@ class Features implements \Iterator
|
|||
{
|
||||
foreach (Options::getFeaturesConfiguration() as $featureName => $sniffs) {
|
||||
if (in_array(get_class($sniff), $sniffs)) {
|
||||
$this->addFeature($featureName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given feature.
|
||||
*
|
||||
* @param string $featureName
|
||||
* @return void
|
||||
*/
|
||||
protected function addFeature($featureName)
|
||||
{
|
||||
if (!class_implements($featureName, FeatureInterface::class)) {
|
||||
throw new \Exception(
|
||||
'Configured Feature "' . $featureName . '" does not implement "' . FeatureInterface::class . '".',
|
||||
1493115488
|
||||
);
|
||||
}
|
||||
|
||||
$this->features[] = $featureName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// implement Iterator interface:
|
||||
public function current()
|
||||
|
|
Loading…
Reference in a new issue