Completed
Push — 2.x ( 0c3f5d...21439c )
by Paul
10s
created

Uppercase::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 2
eloc 5
nc 2
nop 2
crap 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
use Aura\Filter\Rule\AbstractCharCase;
12
13
/**
14
 *
15
 * Validates that the string is all uppercase.
16
 *
17
 * @package Aura.Filter
18
 *
19
 */
20
class Uppercase extends AbstractCharCase
21
{
22
    /**
23
     *
24
     * Validates that the string is uppercase.
25
     *
26
     * @param object $subject The subject to be filtered.
27
     *
28
     * @param string $field The subject field name.
29
     *
30
     * @return bool True if valid, false if not.
31
     *
32
     */
33 9
    public function __invoke($subject, $field)
34
    {
35 9
        $value = $subject->$field;
36 9
        if (! is_scalar($value)) {
37 1
            return false;
38
        }
39
40 8
        return $this->strtoupper($value) == $value;
41
    }
42
}
43