Completed
Push — master ( b4d909...e3c084 )
by Valentyn
03:37
created

UpdateActorRequest::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 12
cts 12
cp 1
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Actors\Request;
4
5
use App\Actors\Entity\Actor;
6
use App\Request\BaseRequest;
7
use Symfony\Component\Validator\Constraints as Assert;
8
9
class UpdateActorRequest extends BaseRequest
10
{
11 2
    public function rules()
12
    {
13 2
        return new Assert\Collection([
14 2
            'actor' => new Assert\Collection([
15
                // Movie
16 2
                'originalName' => [new Assert\NotBlank(), new Assert\Length(['min' => 2, 'max' => 100])],
17 2
                'imdbId' => new Assert\Length(['min' => 5, 'max' => 20]),
18 2
                'birthday' => new Assert\Date(),
19 2
                'gender' => new Assert\Choice([Actor::GENDER_MALE, Actor::GENDER_FEMALE]),
20
                // MovieTranslations[]
21 2
                'translations' => $this->eachItemValidation([
22 2
                    'locale' => [new Assert\NotBlank(), new Assert\Locale()],
23 2
                    'name' => [new Assert\NotBlank(), new Assert\Length(['min' => 2, 'max' => 100])],
24 2
                    'placeOfBirth' => [new Assert\NotBlank(), new Assert\Length(['max' => 100])],
25 2
                    'biography' => [new Assert\NotBlank()],
26
                ]),
27
            ]),
28
        ]);
29
    }
30
}
31