Code Duplication    Length = 23-23 lines in 2 locations

src/system/RoutesModule/Entity/Base/AbstractRouteEntity.php 2 locations

@@ 790-812 (lines=23) @@
787
    /**
788
     * @Assert\Callback()
789
     */
790
    public function isSchemesValueAllowed(ExecutionContextInterface $context)
791
    {
792
        $serviceManager = ServiceUtil::getManager();
793
        $helper = $serviceManager->get('zikula_routes_module.listentries_helper');
794
        $listEntries = $helper->getSchemesEntriesForRoute();
795
    
796
        $allowedValues = [];
797
        foreach ($listEntries as $entry) {
798
            $allowedValues[] = $entry['value'];
799
        }
800
    
801
        $selected = explode('###', $this->schemes);
802
        foreach ($selected as $value) {
803
            if ($value == '') {
804
                continue;
805
            }
806
            if (!in_array($value, $allowedValues, true)) {
807
                $context->buildViolation($serviceManager->get('translator.default')->__('Invalid value provided'))
808
                    ->atPath('schemes')
809
                    ->addViolation();
810
            }
811
        }
812
    }
813
    
814
    /**
815
     * @Assert\Callback()
@@ 817-839 (lines=23) @@
814
    /**
815
     * @Assert\Callback()
816
     */
817
    public function isMethodsValueAllowed(ExecutionContextInterface $context)
818
    {
819
        $serviceManager = ServiceUtil::getManager();
820
        $helper = $serviceManager->get('zikula_routes_module.listentries_helper');
821
        $listEntries = $helper->getMethodsEntriesForRoute();
822
    
823
        $allowedValues = [];
824
        foreach ($listEntries as $entry) {
825
            $allowedValues[] = $entry['value'];
826
        }
827
    
828
        $selected = explode('###', $this->methods);
829
        foreach ($selected as $value) {
830
            if ($value == '') {
831
                continue;
832
            }
833
            if (!in_array($value, $allowedValues, true)) {
834
                $context->buildViolation($serviceManager->get('translator.default')->__('Invalid value provided'))
835
                    ->atPath('methods')
836
                    ->addViolation();
837
            }
838
        }
839
    }
840
    
841
    /**
842
     * Start validation and raise exception if invalid data is found.