Passed
Push — 1.x ( f2d500...759dd0 )
by Milwad
03:21
created

ValidJwt::base64url_encode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Milwad\LaravelValidate\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
class ValidJwt implements Rule
8
{
9
    /**
10
     * Check jwt is valid.
11
     *
12
     * @param  string  $attribute
13
     * @param  mixed  $value
14
     * @return bool
15
     */
16
    public function passes($attribute, $value)
17
    {
18
        return preg_match('/^[a-zA-Z0-9-_]+\.[a-zA-Z0-9-_]+\.[a-zA-Z0-9-_]+$/', $value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return preg_match('/^[a-...zA-Z0-9-_]+$/', $value) returns the type integer which is incompatible with the documented return type boolean.
Loading history...
19
    }
20
21
    /**
22
     * Get the validation error message.
23
     *
24
     * @return string
25
     */
26
    public function message()
27
    {
28
        return __('validate.jwt');
29
    }
30
}
31