ExitProductRequest::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace App\Http\Requests;
4
5
use App\Repositories\InvolvedRepository;
6
7
class ExitProductRequest extends Request
8
{
9
    /**
10
     * @return bool
11
     */
12
    public function authorize()
13
    {
14
        $involve = $this->route()->getParameter('involved');
15
16
        if ($involve
17
            && $this->getInvolvedRepository()->checkIfAuthInvolved($involve->product)
18
        )
19
            if ($involve->active !== 0) {
20
                return true;
21
            }
22
23
        return false;
24
    }
25
26
    /**
27
     * @return array
28
     */
29
    public function rules()
30
    {
31
        return [
32
            'count' => $this->getInvolvedRepository()->countRules()
33
        ];
34
    }
35
36
    /**
37
     * @return InvolvedRepository
38
     */
39
    private function getInvolvedRepository()
40
    {
41
        return (new InvolvedRepository());
42
    }
43
}