@@ -35,9 +35,9 @@ class GeneratorPool
35
35
36
36
/**
37
37
* @param ScheduledStructure\Helper $helper
38
- * @param ConditionFactory $conditionFactory
39
- * @param \Psr\Log\LoggerInterface $logger
40
- * @param array $generators
38
+ * @param ConditionFactory $conditionFactory
39
+ * @param \Psr\Log\LoggerInterface $logger
40
+ * @param array $generators
41
41
*/
42
42
public function __construct (
43
43
ScheduledStructure \Helper $ helper ,
@@ -69,8 +69,9 @@ public function getGenerator($type)
69
69
/**
70
70
* Traverse through all generators and generate all scheduled elements
71
71
*
72
- * @param Reader\Context $readerContext
72
+ * @param Reader\Context $readerContext
73
73
* @param Generator\Context $generatorContext
74
+ *
74
75
* @return $this
75
76
*/
76
77
public function process (Reader \Context $ readerContext , Generator \Context $ generatorContext )
@@ -86,11 +87,17 @@ public function process(Reader\Context $readerContext, Generator\Context $genera
86
87
* Add generators to pool
87
88
*
88
89
* @param GeneratorInterface[] $generators
90
+ *
89
91
* @return void
90
92
*/
91
93
protected function addGenerators (array $ generators )
92
94
{
93
95
foreach ($ generators as $ generator ) {
96
+ if (!$ generator instanceof GeneratorInterface) {
97
+ throw new \InvalidArgumentException (
98
+ sprintf ('Generator class must be an instance of %s ' , GeneratorInterface::class)
99
+ );
100
+ }
94
101
$ this ->generators [$ generator ->getType ()] = $ generator ;
95
102
}
96
103
}
0 commit comments