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.

MaxWords   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 45
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A message() 0 3 1
A __construct() 0 3 1
A make() 0 3 1
A passes() 0 3 1
1
<?php
2
3
namespace ProtoneMedia\LaravelMixins\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
class MaxWords implements Rule
8
{
9
    private int $max;
10
11
    /**
12
     * Create a new rule instance.
13
     *
14
     * @param integer $max
15
     */
16
    public function __construct(int $max)
17
    {
18
        $this->max = $max;
19
    }
20
21
    /**
22
     * Helper method to initialize the rule.
23
     *
24
     * @param integer $max
25
     * @return self
26
     */
27
    public static function make(int $max): self
28
    {
29
        return new static($max);
30
    }
31
32
    /**
33
     * Determine if the validation rule passes.
34
     *
35
     * @param  string  $attribute
36
     * @param  mixed  $value
37
     * @return bool
38
     */
39
    public function passes($attribute, $value)
40
    {
41
        return count(array_filter(explode(' ', $value))) <= $this->max;
42
    }
43
44
    /**
45
     * Get the validation error message.
46
     *
47
     * @return string
48
     */
49
    public function message()
50
    {
51
        return __('validation.max_words');
52
    }
53
}
54