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...
14
{
15
/**
16
* @var array
17
*/
18
private $validators;
19
20
/**
21
* ValidationServiceImplementation constructor.
22
*
23
* @param array $validators
24
*/
25
public function __construct(array $validators)
26
{
27
$this->validators = $validators;
28
29
if (count($validators) < 1) {
30
new \LogicException("You need to provide the validation service with at least 1 validator");
31
}
32
}
33
34
/**
35
* Test a message against a number of validators
36
*
37
* @param Message $message
38
*
39
* @return Status
40
*/
41
public function validate(Message $message) : Status
42
{
43
$statuses = [];
44
45
/** @var Validator $validator */
46
foreach ($this->validators as $validator) {
47
$statuses[] = $validator->validate($message);
48
}
49
50
usort($statuses, function (Status $statusA, Status $statusB) {
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.