Code Duplication    Length = 15-15 lines in 7 locations

src/Options/ModuleOptions.php 7 locations

@@ 304-318 (lines=15) @@
301
     * @return PluginOptions
302
     * @throws \Nnx\JmsSerializerModule\Options\Exception\InvalidArgumentException
303
     */
304
    public function getHandlerRegistry($handlerRegistryName)
305
    {
306
        if (array_key_exists($handlerRegistryName, $this->handlerRegistriesOptions)) {
307
            return $this->handlerRegistriesOptions[$handlerRegistryName];
308
        }
309
310
        if (!$this->hasHandlerRegistry($handlerRegistryName)) {
311
            $errMsg = sprintf('Handler registry %s not found', $handlerRegistryName);
312
            throw new Exception\InvalidArgumentException($errMsg);
313
        }
314
315
        $this->handlerRegistriesOptions[$handlerRegistryName] = new PluginOptions($this->handlerRegistries[$handlerRegistryName]);
316
317
        return $this->handlerRegistriesOptions[$handlerRegistryName];
318
    }
319
320
    /**
321
     * Устанавливает данные описывающие драйверы метаданных
@@ 356-370 (lines=15) @@
353
     * @return PluginOptions
354
     * @throws \Nnx\JmsSerializerModule\Options\Exception\InvalidArgumentException
355
     */
356
    public function getMetadataDriver($metadataDriverName)
357
    {
358
        if (array_key_exists($metadataDriverName, $this->metadataDriversOptions)) {
359
            return $this->metadataDriversOptions[$metadataDriverName];
360
        }
361
362
        if (!$this->hasMetadataDriver($metadataDriverName)) {
363
            $errMsg = sprintf('Metadata driver %s not found', $metadataDriverName);
364
            throw new Exception\InvalidArgumentException($errMsg);
365
        }
366
367
        $this->metadataDriversOptions[$metadataDriverName] = new PluginOptions($this->metadataDrivers[$metadataDriverName]);
368
369
        return $this->metadataDriversOptions[$metadataDriverName];
370
    }
371
372
    /**
373
     * Устанавливает данные описывающие конструкторы объектов
@@ 408-422 (lines=15) @@
405
     * @return PluginOptions
406
     * @throws \Nnx\JmsSerializerModule\Options\Exception\InvalidArgumentException
407
     */
408
    public function getObjectConstructor($objectConstructorName)
409
    {
410
        if (array_key_exists($objectConstructorName, $this->objectConstructorsOptions)) {
411
            return $this->objectConstructorsOptions[$objectConstructorName];
412
        }
413
414
        if (!$this->hasObjectConstructor($objectConstructorName)) {
415
            $errMsg = sprintf('Object constructor %s not found', $objectConstructorName);
416
            throw new Exception\InvalidArgumentException($errMsg);
417
        }
418
419
        $this->objectConstructorsOptions[$objectConstructorName] = new PluginOptions($this->objectConstructors[$objectConstructorName]);
420
421
        return $this->objectConstructorsOptions[$objectConstructorName];
422
    }
423
424
    /**
425
     * Устанавливает набор плагинов используемх для сериализации
@@ 549-563 (lines=15) @@
546
     * @return PluginOptions
547
     * @throws \Nnx\JmsSerializerModule\Options\Exception\InvalidArgumentException
548
     */
549
    public function getEventDispatcher($eventDispatcherName)
550
    {
551
        if (array_key_exists($eventDispatcherName, $this->eventDispatchersOptions)) {
552
            return $this->eventDispatchersOptions[$eventDispatcherName];
553
        }
554
555
        if (!$this->hasEventDispatcher($eventDispatcherName)) {
556
            $errMsg = sprintf('Event dispatcher %s not found', $eventDispatcherName);
557
            throw new Exception\InvalidArgumentException($errMsg);
558
        }
559
560
        $this->eventDispatchersOptions[$eventDispatcherName] = new PluginOptions($this->eventDispatchers[$eventDispatcherName]);
561
562
        return $this->eventDispatchersOptions[$eventDispatcherName];
563
    }
564
565
    /**
566
     * Возвращает сервиса для получения кеша доктрины
@@ 624-638 (lines=15) @@
621
     * @return PluginOptions
622
     * @throws \Nnx\JmsSerializerModule\Options\Exception\InvalidArgumentException
623
     */
624
    public function getFileLocator($fileLocatorName)
625
    {
626
        if (array_key_exists($fileLocatorName, $this->fileLocatorsOptions)) {
627
            return $this->fileLocatorsOptions[$fileLocatorName];
628
        }
629
630
        if (!$this->hasFileLocator($fileLocatorName)) {
631
            $errMsg = sprintf('File locator %s not found', $fileLocatorName);
632
            throw new Exception\InvalidArgumentException($errMsg);
633
        }
634
635
        $this->fileLocatorsOptions[$fileLocatorName] = new PluginOptions($this->fileLocators[$fileLocatorName]);
636
637
        return $this->fileLocatorsOptions[$fileLocatorName];
638
    }
639
640
    /**
641
     * Устанавливает данные описывающие Visitor'ы
@@ 675-689 (lines=15) @@
672
     * @return PluginOptions
673
     * @throws \Nnx\JmsSerializerModule\Options\Exception\InvalidArgumentException
674
     */
675
    public function getVisitor($visitorName)
676
    {
677
        if (array_key_exists($visitorName, $this->visitorsOptions)) {
678
            return $this->visitorsOptions[$visitorName];
679
        }
680
681
        if (!$this->hasVisitor($visitorName)) {
682
            $errMsg = sprintf('Visitor %s not found', $visitorName);
683
            throw new Exception\InvalidArgumentException($errMsg);
684
        }
685
686
        $this->visitorsOptions[$visitorName] = new PluginOptions($this->visitors[$visitorName]);
687
688
        return $this->visitorsOptions[$visitorName];
689
    }
690
691
    /**
692
     * Устанавливает настройки стратегий для работы с именами свойств объектов
@@ 728-742 (lines=15) @@
725
     * @return PluginOptions
726
     * @throws \Nnx\JmsSerializerModule\Options\Exception\InvalidArgumentException
727
     */
728
    public function getNamingStrategy($strategyName)
729
    {
730
        if (array_key_exists($strategyName, $this->namingStrategiesOptions)) {
731
            return $this->namingStrategiesOptions[$strategyName];
732
        }
733
734
        if (!$this->hasNamingStrategy($strategyName)) {
735
            $errMsg = sprintf('Naming strategy %s not found', $strategyName);
736
            throw new Exception\InvalidArgumentException($errMsg);
737
        }
738
739
        $this->namingStrategiesOptions[$strategyName] = new PluginOptions($this->namingStrategies[$strategyName]);
740
741
        return $this->namingStrategiesOptions[$strategyName];
742
    }
743
}
744