Completed
Push — master ( 2e22d6...16a402 )
by Nicolai
01:59
created

Lowercase   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 37
c 0
b 0
f 0
rs 10
wmc 4
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 3 1
A provideCompiler() 0 7 1
A provideEvaluator() 0 11 2
1
<?php
2
3
4
namespace SmartWeb\ModuleTesting\ExpressionLanguage\Functions\String;
5
6
use SmartWeb\ModuleTesting\ExpressionLanguage\Functions\BaseExpressionFunction;
7
8
9
/**
10
 * ExpressionFunction for converting input string to lower-case.
11
 *
12
 * @package SmartWeb\ModuleTesting\ExpressionLanguage\Functions
13
 */
14
class Lowercase extends BaseExpressionFunction
15
{
16
    
17
    /**
18
     * @inheritDoc
19
     */
20
    protected function init()
21
    {
22
    }
23
    
24
    /**
25
     * @inheritDoc
26
     */
27
    protected function provideCompiler() : callable
28
    {
29
        return function ($str)
30
        {
31
            return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str);
32
        };
33
    }
34
    
35
    /**
36
     * @inheritDoc
37
     */
38
    protected function provideEvaluator() : callable
39
    {
40
        return function ($arguments, $str)
41
        {
42
            if (!is_string($str)) {
43
                return $str;
44
            }
45
            
46
            return strtolower($str);
47
        };
48
    }
49
    
50
}
51