Code Duplication    Length = 19-21 lines in 2 locations

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
    {

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

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