Conditions | 3 |
Paths | 1 |
Total Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3.0067 |
Changes | 0 |
1 | <?php |
||
11 | 1 | public function rules() |
|
12 | { |
||
13 | $movieIdRequired = function ($object, ExecutionContextInterface $context, $payload) { |
||
|
|||
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 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.