Completed
Push — master ( 38deb0...7544ac )
by Anton
11s
created

AlphaRule   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validateClean() 0 4 1
A getDescription() 0 7 2
1
<?php
2
/**
3
 * Bluz Framework Component
4
 *
5
 * @copyright Bluz PHP Team
6
 * @link      https://github.com/bluzphp/framework
7
 */
8
9
declare(strict_types=1);
10
11
namespace Bluz\Validator\Rule;
12
13
/**
14
 * Check for alphabetic character(s)
15
 *
16
 * @package Bluz\Validator\Rule
17
 */
18
class AlphaRule extends AbstractCtypeRule
19
{
20
    /**
21
     * Check for alphabetic character(s)
22
     *
23
     * @param  string $input
24
     *
25
     * @return bool
26
     */
27 20
    protected function validateClean($input): bool
28
    {
29 20
        return ctype_alpha($input);
30
    }
31
32
    /**
33
     * Get error template
34
     *
35
     * @return string
36
     */
37 28
    public function getDescription() : string
38
    {
39 28
        if (empty($this->additionalChars)) {
40 22
            return __('must contain only letters');
41
        }
42 7
        return __('must contain only letters and "%s"', $this->additionalChars);
43
    }
44
}
45