Alpha   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 14
ccs 2
cts 2
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A check() 0 7 4
1
<?php
2
3
/**
4
 * This file is part of Dimtrovich/Validation.
5
 *
6
 * (c) 2023 Dimitri Sitchet Tomkeu <[email protected]>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace Dimtrovich\Validation\Rules;
13
14
class Alpha extends AbstractRule
15
{
16
    protected $fillableParams = ['mode'];
17
18
    /**
19
     * {@inheritDoc}
20
     */
21
    public function check($value): bool
22
    {
23
        if ($this->parameter('mode') === 'ascii') {
24 2
            return is_string($value) && preg_match('/\A[a-zA-Z]+\z/u', $value);
25
        }
26
27 2
        return is_string($value) && preg_match('/\A[\pL\pM]+\z/u', $value);
28
    }
29
}
30