Passed
Push — master ( ab2678...bf154d )
by webdevetc
14:17
created

SearchRequest::authorize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace WebDevEtc\BlogEtc\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
7
/**
8
 * Class SearchRequest.
9
 */
10
class SearchRequest extends FormRequest
11
{
12
    /**
13
     * Can user view the search section?
14
     */
15
    public function authorize(): bool
16
    {
17
        return true === config('blogetc.search.search_enabled');
18
    }
19
20
    /**
21
     * Get the validation rules that apply to the request.
22
     */
23
    public function rules(): array
24
    {
25
        return [
26
            's' => ['nullable', 'string', 'min:3', 'max:40'],
27
        ];
28
    }
29
30
    /**
31
     * Return the query that user searched for.
32
     */
33
    public function searchQuery(): string
34
    {
35
        return $this->get('s', '');
36
    }
37
}
38