Code Duplication    Length = 15-15 lines in 6 locations

src/Options/ModuleOptions.php 6 locations

@@ 219-233 (lines=15) @@
216
     * @return PluginOptions
217
     * @throws \Nnx\JmsSerializerModule\Options\Exception\InvalidArgumentException
218
     */
219
    public function gasMetadataFactory($metadataFactoryName)
220
    {
221
        if (array_key_exists($metadataFactoryName, $this->metadataFactoriesOptions)) {
222
            return $this->metadataFactoriesOptions[$metadataFactoryName];
223
        }
224
225
        if (!$this->hasMetadataFactory($metadataFactoryName)) {
226
            $errMsg = sprintf('Config for metadata factory %s not found', $metadataFactoryName);
227
            throw new Exception\InvalidArgumentException($errMsg);
228
        }
229
230
        $this->metadataFactoriesOptions[$metadataFactoryName] = new PluginOptions($this->metadataFactories[$metadataFactoryName]);
231
232
        return $this->metadataFactoriesOptions[$metadataFactoryName];
233
    }
234
235
    /**
236
     * Устанавливает данные для хранилища хенделеров сериалайзера
@@ 270-284 (lines=15) @@
267
     * @return PluginOptions
268
     * @throws \Nnx\JmsSerializerModule\Options\Exception\InvalidArgumentException
269
     */
270
    public function getHandlerRegistry($handlerRegistryName)
271
    {
272
        if (array_key_exists($handlerRegistryName, $this->handlerRegistriesOptions)) {
273
            return $this->handlerRegistriesOptions[$handlerRegistryName];
274
        }
275
276
        if (!$this->hasHandlerRegistry($handlerRegistryName)) {
277
            $errMsg = sprintf('Handler registry %s not found', $handlerRegistryName);
278
            throw new Exception\InvalidArgumentException($errMsg);
279
        }
280
281
        $this->handlerRegistriesOptions[$handlerRegistryName] = new PluginOptions($this->handlerRegistriesOptions[$handlerRegistryName]);
282
283
        return $this->handlerRegistriesOptions[$handlerRegistryName];
284
    }
285
286
    /**
287
     * Устанавливает данные описывающие драйверы метаданных
@@ 322-336 (lines=15) @@
319
     * @return PluginOptions
320
     * @throws \Nnx\JmsSerializerModule\Options\Exception\InvalidArgumentException
321
     */
322
    public function getMetadataDriver($metadataDriverName)
323
    {
324
        if (array_key_exists($metadataDriverName, $this->metadataDriversOptions)) {
325
            return $this->metadataDriversOptions[$metadataDriverName];
326
        }
327
328
        if (!$this->hasMetadataDriver($metadataDriverName)) {
329
            $errMsg = sprintf('Metadata driver %s not found', $metadataDriverName);
330
            throw new Exception\InvalidArgumentException($errMsg);
331
        }
332
333
        $this->metadataDriversOptions[$metadataDriverName] = new PluginOptions($this->metadataDrivers[$metadataDriverName]);
334
335
        return $this->metadataDriversOptions[$metadataDriverName];
336
    }
337
338
    /**
339
     * Устанавливает данные описывающие конструкторы объектов
@@ 374-388 (lines=15) @@
371
     * @return PluginOptions
372
     * @throws \Nnx\JmsSerializerModule\Options\Exception\InvalidArgumentException
373
     */
374
    public function getObjectConstructor($objectConstructorName)
375
    {
376
        if (array_key_exists($objectConstructorName, $this->objectConstructorsOptions)) {
377
            return $this->objectConstructorsOptions[$objectConstructorName];
378
        }
379
380
        if (!$this->hasObjectConstructor($objectConstructorName)) {
381
            $errMsg = sprintf('Object constructor %s not found', $objectConstructorName);
382
            throw new Exception\InvalidArgumentException($errMsg);
383
        }
384
385
        $this->objectConstructorsOptions[$objectConstructorName] = new PluginOptions($this->objectConstructors[$objectConstructorName]);
386
387
        return $this->objectConstructorsOptions[$objectConstructorName];
388
    }
389
390
    /**
391
     * Устанавливает набор плагинов используемх для сериализации
@@ 515-529 (lines=15) @@
512
     * @return PluginOptions
513
     * @throws \Nnx\JmsSerializerModule\Options\Exception\InvalidArgumentException
514
     */
515
    public function getEventDispatcher($eventDispatcherName)
516
    {
517
        if (array_key_exists($eventDispatcherName, $this->eventDispatchersOptions)) {
518
            return $this->eventDispatchersOptions[$eventDispatcherName];
519
        }
520
521
        if (!$this->hasEventDispatcher($eventDispatcherName)) {
522
            $errMsg = sprintf('Event dispatcher %s not found', $eventDispatcherName);
523
            throw new Exception\InvalidArgumentException($errMsg);
524
        }
525
526
        $this->eventDispatchersOptions[$eventDispatcherName] = new PluginOptions($this->eventDispatchers[$eventDispatcherName]);
527
528
        return $this->eventDispatchersOptions[$eventDispatcherName];
529
    }
530
531
    /**
532
     * Устанавливает набор данных описывающих парсеры типов
@@ 567-581 (lines=15) @@
564
     * @return PluginOptions
565
     * @throws \Nnx\JmsSerializerModule\Options\Exception\InvalidArgumentException
566
     */
567
    public function getTypeParser($typeParserName)
568
    {
569
        if (array_key_exists($typeParserName, $this->typeParsersOptions)) {
570
            return $this->typeParsersOptions[$typeParserName];
571
        }
572
573
        if (!$this->hasTypeParser($typeParserName)) {
574
            $errMsg = sprintf('Type parser %s not found', $typeParserName);
575
            throw new Exception\InvalidArgumentException($errMsg);
576
        }
577
578
        $this->typeParsersOptions[$typeParserName] = new PluginOptions($this->typeParsers[$typeParserName]);
579
580
        return $this->typeParsersOptions[$typeParserName];
581
    }
582
}
583