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

NewMovieCardRequest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 6
dl 0
loc 22
rs 10
c 0
b 0
f 0
ccs 12
cts 12
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A rules() 0 19 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