Completed
Push — master ( 058e40...9e132c )
by Valentyn
04:01
created

CreateMovieRequest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 8

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 8
dl 0
loc 33
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A rules() 0 30 1
1
<?php
2
3
namespace App\Movies\Request;
4
5
use App\Request\BaseRequest;
6
use Symfony\Component\Validator\Constraints as Assert;
7
8
class CreateMovieRequest extends BaseRequest
9
{
10 3
    public function rules()
11
    {
12 3
        return new Assert\Collection([
13 3
            'movie' => new Assert\Collection([
14
                // Movie
15 3
                'originalTitle' => [new Assert\NotBlank(), new Assert\Length(['min' => 2, 'max' => 100])],
16 3
                'originalPosterUrl' => [new Assert\NotBlank(), new Assert\Length(['min' => 10, 'max' => 255])],
17 3
                'imdbId' => new Assert\Length(['min' => 5, 'max' => 20]),
18 3
                'runtime' => new Assert\Type(['type' => 'integer']),
19 3
                'budget' => new Assert\Type(['type' => 'integer']),
20 3
                'releaseDate' => new Assert\Date(),
21
                // MovieTranslations[]
22 3
                'translations' => $this->eachItemValidation([
23 3
                    'locale' => [new Assert\NotBlank(), new Assert\Locale()],
24 3
                    'title' => [new Assert\NotBlank(), new Assert\Length(['min' => 3, 'max' => 50])],
25 3
                    'posterUrl' => [new Assert\NotBlank(), new Assert\Length(['min' => 10, 'max' => 255])],
26 3
                    'overview' => [new Assert\NotBlank(), new Assert\Length(['min' => 50])],
27
                ]),
28 3
                'genres' => $this->eachItemValidation([
29 3
                    'id' => [new Assert\NotBlank(), new Assert\Type('integer')],
30
                ]),
31
                // MovieTMDB
32 3
                'tmdb' => new Assert\Collection([
33 3
                    'id' => [new Assert\NotBlank(), new Assert\Type(['type' => 'integer'])],
34 3
                    'voteAverage' => new Assert\Range(['min' => 0.0, 'max' => 10.0]),
35 3
                    'voteCount' => new Assert\Type(['type' => 'integer']),
36
                ]),
37
            ]),
38
        ]);
39
    }
40
}
41