UsernameWithoutIllegalWords::message()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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