Completed
Push — master ( 71eba9...1e1a94 )
by Valentyn
04:31
created

NewMovieCardRequest::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
rs 9.6333
c 0
b 0
f 0
ccs 12
cts 12
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Movies\Request;
4
5
use App\Movies\Entity\MovieCard;
6
use App\Request\BaseRequest;
7
use Symfony\Component\Validator\Constraints as Assert;
8
use Symfony\Component\Validator\Context\ExecutionContextInterface;
9
10
class NewMovieCardRequest extends BaseRequest
11
{
12 1
    public function rules()
13
    {
14
        $cardTypes = [
15 1
            MovieCard::TYPE_WATCH,
16 1
            MovieCard::TYPE_WATCH_FREE,
17 1
            MovieCard::TYPE_DOWNLOAD,
18 1
            MovieCard::TYPE_REVIEW,
19 1
            MovieCard::TYPE_TRAILER
20
        ];
21
22 1
        return new Assert\Collection([
23 1
            'card' => new Assert\Collection([
24 1
                'title' => [new Assert\NotBlank(), new Assert\Length(['min' => 2, 'max' => 255])],
25 1
                'description' => new Assert\Length(['max' => 255]),
26 1
                'url' => [new Assert\NotBlank(), new Assert\Length(['max' => 255]), new Assert\Url()],
27 1
                'type' => [new Assert\NotBlank(), new Assert\Choice($cardTypes)],
28
            ]),
29
        ]);
30
    }
31
}
32