Passed
Push — stage ( a7e110...431749 )
by Jon
06:24
created

ValidatesGithubRepo::message()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Rules;
4
5
use App\Services\Publish\GitHubService;
6
use Illuminate\Contracts\Validation\Rule;
7
8
class ValidatesGithubRepo implements Rule
9
{
10
    /**
11
     * Create a new rule instance.
12
     *
13
     * @return void
14
     */
15
    public function __construct()
16
    {
17
        //
18
    }
19
20
    /**
21
     * Determine if the validation rule passes.
22
     *
23
     * @param  string  $attribute
24
     * @param  mixed  $value
25
     * @return bool
26
     */
27
    public function passes($attribute, $value)
28
    {
29
        if ($value) {
30
            return GitHubService::GetPublicRepo($value) !== false;
31
        }
32
33
        return true;
34
    }
35
36
    /**
37
     * Get the validation error message.
38
     *
39
     * @return string
40
     */
41
    public function message()
42
    {
43
        return "You must supply a valid GitHub repository path in the form of: 'User/Repository";
44
    }
45
}
46