Completed
Push — master ( ac7de6...93eb40 )
by Valentyn
07:02
created

RemoveMovieRecommendationRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 6
dl 0
loc 21
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A rules() 0 18 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 RemoveMovieRecommendationRequest extends BaseRequest
10
{
11
    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
            $data = $context->getRoot();
15
            $tmdb_id = $data['tmdb_id'] ?? null;
16
            $id = $data['movie_id'] ?? null;
17
18
            if (empty($tmdb_id) && empty($id)) {
19
                $context->buildViolation('Movie Id or TMDB Id should be provided')->addViolation();
20
            }
21
        };
22
23
        return new Assert\Collection([
24
            'api_token' => new Assert\NotBlank(),
25
            'movie_id' => new Assert\Callback($movieIdRequired),
26
            'tmdb_id' => new Assert\Callback($movieIdRequired),
27
        ]);
28
    }
29
}
30