Completed
Push — master ( c501e5...95579c )
by Kamil
08:05 queued 04:53
created

ShopUserDoesNotExistValidator::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sylius\ShopApiPlugin\Validator;
6
7
use Sylius\Component\User\Repository\UserRepositoryInterface;
8
use Symfony\Component\Validator\Constraint;
9
use Symfony\Component\Validator\ConstraintValidator;
10
11 View Code Duplication
final class ShopUserDoesNotExistValidator extends ConstraintValidator
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    /**
14
     * @var UserRepositoryInterface
15
     */
16
    private $userRepository;
17
18
    public function __construct(UserRepositoryInterface $userRepository)
19
    {
20
        $this->userRepository = $userRepository;
21
    }
22
23
    public function validate($email, Constraint $constraint)
24
    {
25
        if (null !== $this->userRepository->findOneByEmail($email)) {
26
            $this->context->addViolation($constraint->message);
27
        }
28
    }
29
}
30