Completed
Push — master ( d15cf4...5163a0 )
by Valentyn
06:05
created

CreateMovieRequest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
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 30
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

1 Method

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