Completed
Branch master (a6481d)
by Fèvre
02:09
created

CommentValidator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 13 2
1
<?php
2
namespace Xetaravel\Models\Validators;
3
4
use Illuminate\Support\Facades\Validator as FacadeValidator;
5
use Illuminate\Validation\Validator;
6
use Mews\Purifier\Facades\Purifier;
7
8
class CommentValidator
9
{
10
    /**
11
     * Get a validator for an incoming create request.
12
     *
13
     * @param array $data The data to validate.
14
     *
15
     * @return \Illuminate\Validation\Validator
16
     */
17
    public static function create(array $data): Validator
18
    {
19
        $rules = [
20
            'content' => 'required|min:10',
21
            'article_id' => 'required'
22
        ];
23
24
        if (isset($data['content'])) {
25
            $data['content'] = Purifier::clean($data['content'], 'blog_comment_empty');
26
        }
27
28
        return FacadeValidator::make($data, $rules);
29
    }
30
}
31