Alpha   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 23
ccs 5
cts 5
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 2
1
<?php
2
/**
3
 *
4
 * This file is part of Aura for PHP.
5
 *
6
 * @license http://opensource.org/licenses/bsd-license.php BSD
7
 *
8
 */
9
namespace Aura\Filter\Rule\Validate;
10
11
/**
12
 *
13
 * Validates that the value is letters only (upper or lower case).
14
 *
15
 * @package Aura.Filter
16
 *
17
 */
18
class Alpha
19
{
20
    /**
21
     *
22
     * Validates that the value is letters only (upper or lower case).
23
     *
24
     * @param object $subject The subject to be filtered.
25
     *
26
     * @param string $field The subject field name.
27
     *
28
     * @return bool True if valid, false if not.
29
     *
30
     */
31 19
    public function __invoke($subject, $field)
32
    {
33 19
        $value = $subject->$field;
34 19
        if (! is_scalar($value)) {
35 1
            return false;
36
        }
37
38 18
        return (bool) preg_match('/^[\p{L}]+$/u', $value);
39
    }
40
}
41