GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( 825fca...40a20f )
by Roelof Jan
04:11 queued 12s
created

Unique::message()   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
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace AloiaCms\Validation\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
class Unique implements Rule
8
{
9
    protected string $model;
10
11
    /**
12
     * Create a new rule instance.
13
     *
14
     * @return void
15
     */
16
    public function __construct(string $model)
17
    {
18
        $this->model = $model;
19
    }
20
21
    /**
22
     * Determine if the validation rule passes.
23
     *
24
     * @param  string  $attribute
25
     * @param  mixed  $value
26
     * @return bool
27
     */
28
    public function passes($attribute, $value)
29
    {
30
        $model = $this->createModel();
31
32
        $instance = $model->findById($value);
33
34
        return !$instance->exists();
35
    }
36
37
    /**
38
     * Get the validation error message.
39
     *
40
     * @return string
41
     */
42
    public function message()
43
    {
44
        return 'The model is not unique.';
45
    }
46
47
    /**
48
     * Create a new instance of the model.
49
     *
50
     * @return \AloiaCms\Models\Model
51
     */
52
    private function createModel()
53
    {
54
        $class = '\\'.ltrim($this->model, '\\');
55
56
        return new $class;
57
    }
58
}
59