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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 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