Completed
Push — master ( 2b96a9...428378 )
by Valentyn
04:33
created

NewMovieRecommendationRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 5
dl 0
loc 22
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A rules() 0 19 3
1
<?php
2
3
namespace App\Movies\Request;
4
5
use App\Request\BaseRequest;
6
use Symfony\Component\Validator\Constraints as Assert;
7
use Symfony\Component\Validator\Context\ExecutionContextInterface;
8
9
class NewMovieRecommendationRequest extends BaseRequest
10
{
11 1
    public function rules()
12
    {
13
        $movieIdRequired = function ($object, ExecutionContextInterface $context, $payload) {
0 ignored issues
show
Unused Code introduced by
The parameter $payload is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
14 1
            $data = $context->getRoot()['recommendation'];
15 1
            $tmdb_id = $data['tmdb_id'] ?? null;
16 1
            $id = $data['movie_id'] ?? null;
17
18 1
            if (empty($tmdb_id) && empty($id)) {
19
                $context->buildViolation('Movie Id or TMDB Id should be provided')->addViolation();
20
            }
21 1
        };
22
23 1
        return new Assert\Collection([
24 1
            'recommendation' => new Assert\Collection([
25 1
                'movie_id' => new Assert\Callback($movieIdRequired),
26 1
                'tmdb_id' => new Assert\Callback($movieIdRequired),
27
            ]),
28
        ]);
29
    }
30
}
31