Code Duplication    Length = 19-21 lines in 2 locations

src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ConfigurationStructureValidator.php 1 location

@@ 53-73 (lines=21) @@
50
        $this->emailTemplatesConfigurationValidator = $emailTemplatesConfigurationValidator;
51
    }
52
53
    public function validate($value, Constraint $constraint)
54
    {
55
        /** @var \Symfony\Component\Validator\Violation\ConstraintViolationBuilder|false $violation */
56
        $violation = false;
57
58
        try {
59
            $decoded = $this->decodeJson($value);
60
            $this->validateRoot($decoded);
61
        } catch (AssertionException $exception) {
62
            // method is not in the interface yet, but the old method is deprecated.
63
            $violation = $this->context->buildViolation($exception->getMessage());
64
            $violation->atPath($exception->getPropertyPath());
65
        } catch (CoreInvalidArgumentException $exception) {
66
            $violation = $this->context->buildViolation($exception->getMessage());
67
        }
68
69
        if ($violation) {
70
            // ensure we have a sensible path.
71
            $violation->addViolation();
72
        }
73
    }
74
75
    private function decodeJson($rawValue)
76
    {

src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ReconfigureInstitutionRequestValidator.php 1 location

@@ 49-67 (lines=19) @@
46
        $this->configuredInstitutionsService = $configuredInstitutionsService;
47
    }
48
49
    public function validate($value, Constraint $constraint)
50
    {
51
        /** @var \Symfony\Component\Validator\Violation\ConstraintViolationBuilder|false $violation */
52
        $violation = false;
53
54
        try {
55
            $this->validateRoot($value);
56
        } catch (AssertionException $exception) {
57
            // method is not in the interface yet, but the old method is deprecated.
58
            $violation = $this->context->buildViolation($exception->getMessage());
59
            $violation->atPath($exception->getPropertyPath());
60
        } catch (CoreInvalidArgumentException $exception) {
61
            $violation = $this->context->buildViolation($exception->getMessage());
62
        }
63
64
        if ($violation) {
65
            $violation->addViolation();
66
        }
67
    }
68
69
    public function validateRoot(array $configuration)
70
    {