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...
15
{
16
/**
17
* @var LeadRepository
18
*/
19
protected $repositoryLead;
20
21
/**
22
* NotCreatedSameLeadValidator constructor.
23
* @param LeadRepository $repositoryLead
24
*/
25
public function __construct(LeadRepository $repositoryLead)
26
{
27
$this->repositoryLead = $repositoryLead;
28
}
29
30
public function validate($value, Constraint $constraint)
31
{
32
if (!$constraint instanceof LeadExist) {
33
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\LeadExist');
34
}
35
36
/** @var Lead $lead */
37
$lead = $this->context->getRoot()->getData();
38
if ($this->repositoryLead->leadExist($lead->getOrigin(), $lead->getExternalReference())) {
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.