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

Lowercase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

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\Sanitize;
10
11
use Aura\Filter\Rule\AbstractCharCase;
12
13
/**
14
 *
15
 * Sanitizes a string to lowercase.
16
 *
17
 * @package Aura.Filter
18
 *
19
 */
20
class Lowercase extends AbstractCharCase
21
{
22
    /**
23
     *
24
     * Sanitizes a string to lowercase.
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 the value was sanitized, false if not.
31
     *
32
     */
33 8
    public function __invoke($subject, $field)
34
    {
35 8
        $value = $subject->$field;
36 8
        if (! is_scalar($value)) {
37 1
            return false;
38
        }
39 7
        $subject->$field = $this->strtolower($value);
40 7
        return true;
41
    }
42
}
43