Completed
Pull Request — master (#430)
by Anton
04:21
created

AlphaRule::validateClean()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
    protected function validateClean($input): bool
28
    {
29
        return ctype_alpha($input);
30
    }
31
32
    /**
33
     * Get error template
34
     *
35
     * @return string
36
     */
37
    public function getDescription() : string
38
    {
39
        if (empty($this->additionalChars)) {
40
            return __('must contain only letters');
41
        }
42
        return __('must contain only letters and "%s"', $this->additionalChars);
43
    }
44
}
45