Boolean::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
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\AbstractBoolean;
12
13
/**
14
 *
15
 * Validates that the value is a boolean representation.
16
 *
17
 * @package Aura.Filter
18
 *
19
 */
20
class Boolean extends AbstractBoolean
21
{
22
    /**
23
     *
24
     * Validates that the value is a boolean representation.
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 35
    public function __invoke($subject, $field)
34
    {
35 35
        $value = $subject->$field;
36 35
        return $this->isTrue($value) || $this->isFalse($value);
37
    }
38
}
39