From 370015e7c057afb306978b0f95a2ff685d2b1600 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 16:36:12 +0200 Subject: [PATCH] TASK: Refactor code * Reduce indentation. * Provide internal API to add new feature with necessary checks. --- .../Typo3Update/Feature/Features.php | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Standards/Typo3Update/Feature/Features.php b/src/Standards/Typo3Update/Feature/Features.php index 386b99c..4db9e97 100644 --- a/src/Standards/Typo3Update/Feature/Features.php +++ b/src/Standards/Typo3Update/Feature/Features.php @@ -47,17 +47,29 @@ class Features implements \Iterator { foreach (Options::getFeaturesConfiguration() as $featureName => $sniffs) { if (in_array(get_class($sniff), $sniffs)) { - if (!class_implements($featureName, FeatureInterface::class)) { - throw new \Exception( - 'Configured Feature "' . $featureName . '" does not implement "' . FeatureInterface::class . '".', - 1493115488 - ); - } - $this->features[] = $featureName; + $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() {