UsernameWithoutIllegalWords   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A passes() 0 10 3
A message() 0 4 1
1
<?php
2
3
namespace Torralbodavid\DuckFunkCore\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
class UsernameWithoutIllegalWords implements Rule
8
{
9
    const ILLEGAL_WORDS = [
10
        'MOD-',
11
    ];
12
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function passes($attribute, $value)
17
    {
18
        foreach (self::ILLEGAL_WORDS as $bannedWords) {
19
            if (stripos($value, $bannedWords) !== false) {
20
                return false;
21
            }
22
        }
23
24
        return true;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function message()
31
    {
32
        return 'validation.user.illegal.words';
33
    }
34
}
35