Completed
Push — master ( 06b292...adafac )
by Nicolai
02:22
created

Lowercase   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
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\Testing\ExpressionLanguage\Functions
13
 */
14
class Lowercase extends BaseExpressionFunction
15
{
16
    
17
    /**
18
     * @inheritDoc
19
     */
20
    protected function provideCompiler() : callable
21
    {
22
        return function ($str)
23
        {
24
            return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str);
25
        };
26
    }
27
    
28
    /**
29
     * @inheritDoc
30
     */
31
    protected function provideEvaluator() : callable
32
    {
33
        return function ($arguments, $str)
34
        {
35
            if (!is_string($str)) {
36
                return $str;
37
            }
38
            
39
            return strtolower($str);
40
        };
41
    }
42
    
43
}