Passed
Push — master ( eabfa3...2db6fa )
by Petr
04:00
created

CreateBand::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
ccs 0
cts 6
cp 0
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 6
1
<?php
2
3
namespace AppBundle\Entity\DTO;
4
5
use Symfony\Component\Validator\Constraints as Assert;
6
use Symfony\Component\Validator\Context\ExecutionContextInterface;
7
8
/**
9
 * @author Vehsamrak
10
 */
11
class CreateBand
12
{
13
    /**
14
     * @var string
15
     * @Assert\NotBlank(message="Parameter is mandatory: name.")
16
     */
17
    public $name;
18
19
    /**
20
     * @var string
21
     * @Assert\NotBlank(message="Parameter is mandatory: description.")
22
     */
23
    public $description;
24
25
    /**
26
     * @var string[]
27
     * @Assert\NotBlank(message="Parameter is mandatory: members.")
28
     */
29
    public $members;
30
31
    /**
32
     * @Assert\Callback
33
     */
34
    public function validate(ExecutionContextInterface $context)
35
    {
36
        if (!is_array($this->members)) {
37
            $context->buildViolation('Members must be an array.')
38
                    ->atPath('members')
39
                    ->addViolation();
40
        }
41
    }
42
}
43