GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Branch master (bd52da)
by Andrey
04:54 queued 01:45
created

ValidationMiddleware::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A 0 17 3
1
<?php
2
3
/**
4
 * (c) itmedia.by <[email protected]>
5
 */
6
7
namespace Itmedia\CommandBusBundle\Middleware;
8
9
use Itmedia\CommandBusBundle\Command\Command;
10
use Itmedia\CommandBusBundle\Exception\ValidationException;
11
use Symfony\Component\Validator\ConstraintViolationInterface;
12
use Symfony\Component\Validator\Validator\ValidatorInterface;
13
14
/**
15
 * Валидатор сообщение с помощью компонента Symfony\Component\Validator
16
 */
17
class ValidationMiddleware implements Middleware
18
{
19
    /**
20
     * @var ValidatorInterface
21
     */
22
    private $validator;
23
24
    /**
25
     * ValidationMiddleware constructor.
26
     *
27
     * @param ValidatorInterface $validator
28
     */
29
    public function __construct(ValidatorInterface $validator)
30
    {
31
        $this->validator = $validator;
32
    }
33
34
35
    public function handle(Command $message)
36
    {
37
        $violations = $this->validator->validate($message);
38
39
        if (count($violations) !== 0) {
40
            $errors = [];
41
42
            /**
43
             * @var $violation ConstraintViolationInterface
44
             */
45
            foreach ($violations as $violation) {
46
                $errors[$violation->getPropertyPath()] = $violation->getMessage();
47
            }
48
49
            throw new ValidationException($errors);
50
        }
51
    }
52
}
53