Passed
Push — dev ( 69b6f1...3c5138 )
by Chris
12:29 queued 05:29
created

LinkedInUrlRule::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 App\Services\Validation\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
use Illuminate\Support\Facades\Lang;
7
8
class LinkedInUrlRule implements Rule
9
{
10
    /**
11
     * Validation for linkedIn profile URLS.
12
     *
13
     * @var string
14
     */
15
    const PATTERN = '^https:\/\/[a-z]{2,3}\.linkedin\.com\/.*$';
16
17
    /**
18
     * Determine if the validation rule passes.
19
     *
20
     * @param  string  $attribute
2 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
21
     * @param  mixed   $value
2 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 3 found
Loading history...
22
     * @return boolean
23
     */
24
    public function passes($attribute, $value)
1 ignored issue
show
introduced by
Method \App\Services\Validation\Rules\LinkedInUrlRule::passes() does not have parameter type hint for its parameter $attribute but it should be possible to add it based on @param annotation "string".
Loading history...
introduced by
Method \App\Services\Validation\Rules\LinkedInUrlRule::passes() does not have return type hint for its return value but it should be possible to add it based on @return annotation "boolean".
Loading history...
Coding Style introduced by
Type hint "string" missing for $attribute
Loading history...
25
    {
26
        return preg_match('/' . self::PATTERN . '/', $value);
27
    }
28
29
    /**
30
     * Get the validation error message.
31
     *
32
     * @return string
33
     */
34
    public function message()
0 ignored issues
show
introduced by
Method \App\Services\Validation\Rules\LinkedInUrlRule::message() does not have return type hint for its return value but it should be possible to add it based on @return annotation "string".
Loading history...
35
    {
36
        return Lang::get('validation.custom.linkedin_url');
37
    }
38
}
39