@@ -361,10 +361,20 @@ private function doConditionsApply(array $conditions, IO $collectorIO): bool
361361 */
362362 private function getHookPlugins (): array
363363 {
364- if ($ this ->hookPlugins ! == null ) {
365- return $ this ->hookPlugins ;
364+ if ($ this ->hookPlugins == null ) {
365+ $ this ->hookPlugins = $ this -> setupHookPlugins () ;
366366 }
367+ return $ this ->hookPlugins ;
368+ }
367369
370+ /**
371+ *
372+ * Setup configured hook plugins
373+ *
374+ * @return array<Plugin\Hook>
375+ */
376+ private function setupHookPlugins (): array
377+ {
368378 $ this ->hookPlugins = [];
369379
370380 foreach ($ this ->config ->getPlugins () as $ pluginConfig ) {
@@ -379,10 +389,7 @@ private function getHookPlugins(): array
379389 IO ::VERBOSE
380390 );
381391
382- if (
383- is_a ($ pluginClass , Constrained::class, true )
384- && !$ pluginClass ::getRestriction ()->isApplicableFor ($ this ->hook )
385- ) {
392+ if ($ this ->isPluginApplicableForCurrentHook ($ pluginClass )) {
386393 $ this ->io ->write ('Skipped because plugin is not applicable for hook ' . $ this ->hook , true , IO ::VERBOSE );
387394 continue ;
388395 }
@@ -437,4 +444,14 @@ private function checkHookScript(): void
437444 $ inspector = new Inspector ($ this ->hook , $ this ->io , $ this ->repository );
438445 $ inspector ->inspect ();
439446 }
447+
448+ /**
449+ * @param string $pluginClass
450+ * @return bool
451+ */
452+ private function isPluginApplicableForCurrentHook (string $ pluginClass ): bool
453+ {
454+ return is_a ($ pluginClass , Constrained::class, true )
455+ && !$ pluginClass ::getRestriction ()->isApplicableFor ($ this ->hook );
456+ }
440457}
0 commit comments