Passed
Push — 5.0.0 ( b29d18...60ee56 )
by Fèvre
05:16
created

DiscussConversationValidator::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 1
dl 0
loc 15
rs 9.9666
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A DiscussConversationValidator::update() 0 14 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Models\Validators;
6
7
use Illuminate\Support\Facades\Validator as FacadeValidator;
8
use Illuminate\Validation\Rule;
9
use Illuminate\Validation\Validator;
10
use Xetaravel\Models\DiscussCategory;
11
12
class DiscussConversationValidator
13
{
14
    /**
15
     * Get a validator for an incoming update request.
16
     *
17
     * @param array $data The data to validate.
18
     * @param int $id The actual article id to ignore the slug rule.
19
     *
20
     * @return Validator
21
     */
22
    public static function update(array $data, int $id): Validator
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

22
    public static function update(array $data, /** @scrutinizer ignore-unused */ int $id): Validator

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

Loading history...
23
    {
24
        $categories = DiscussCategory::pluckLocked('id');
25
26
        $rules = [
27
            'title' => 'required|min:5',
28
            'category_id' => [
29
                'required',
30
                'integer',
31
                Rule::in($categories->toArray())
32
            ]
33
        ];
34
35
        return FacadeValidator::make($data, $rules);
36
    }
37
}
38