| 1 | <?php |
||
| 2 | |||
| 3 | namespace Rvdlee\ZfImageOptimiser\Factory\Adapter; |
||
| 4 | |||
| 5 | use Interop\Container\ContainerInterface; |
||
| 6 | use Zend\ServiceManager\Factory\FactoryInterface; |
||
| 7 | use Zend\Validator\ValidatorChain; |
||
| 8 | |||
| 9 | abstract class AbstractImageOptimiserFactory implements FactoryInterface |
||
| 10 | { |
||
| 11 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
||
| 12 | { |
||
| 13 | /** @var array $config */ |
||
| 14 | $config = $container->get('config'); |
||
| 15 | |||
| 16 | $binaryOptions = []; |
||
| 17 | if (isset($config['rvdlee']['zf-image-optimiser'][$requestedName]['binary-options'])) { |
||
| 18 | $binaryOptions = $config['rvdlee']['zf-image-optimiser'][$requestedName]['binary-options']; |
||
| 19 | } |
||
| 20 | |||
| 21 | $validatorChain = []; |
||
| 22 | if (isset($config['rvdlee']['zf-image-optimiser'][$requestedName]['validator-chain'])) { |
||
| 23 | $validatorChainConfigs = $config['rvdlee']['zf-image-optimiser'][$requestedName]['validator-chain']; |
||
| 24 | |||
| 25 | $validatorChain = new ValidatorChain(); |
||
| 26 | /** @var array $validatorChainConfig */ |
||
| 27 | foreach ($validatorChainConfigs as $validatorChainConfig) { |
||
| 28 | if (class_exists($validatorChainConfig['name'])) { |
||
| 29 | $validatorConfig = isset($validatorChainConfig['options']) ? $validatorChainConfig['options'] : []; |
||
| 30 | $validator = new $validatorChainConfig['name']($validatorConfig); |
||
| 31 | $validatorChain->attach($validator); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | return [ |
||
|
0 ignored issues
–
show
|
|||
| 37 | $binaryOptions, |
||
| 38 | $validatorChain |
||
| 39 | ]; |
||
| 40 | } |
||
| 41 | } |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: