StrToLower   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 27
ccs 9
cts 9
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getRuleCode() 0 3 1
A apply() 0 6 1
A validate() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Oliverde8\Component\RuleEngine\Rules;
6
7
/**
8
 * Class StrToLower
9
 *
10
 * @author    de Cramer Oliver<[email protected]>
11
 * @copyright 2018 Oliverde8
12
 * @package Oliverde8\Component\RuleEngine\Rules
13
 */
14
class StrToLower extends AbstractRule
15
{
16
    /**
17
     * @inheritdoc
18
     */
19 1
    public function apply(array $rowData, array &$transformedData, array $options = []): string
20
    {
21 1
        $value = $options['value'];
22 1
        unset($options['value']);
23
24 1
        return strtolower($this->ruleApplier->apply($rowData, $transformedData, $value, $options));
0 ignored issues
show
Bug introduced by
It seems like $this->ruleApplier->appl...Data, $value, $options) can also be of type null; however, parameter $string of strtolower() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

24
        return strtolower(/** @scrutinizer ignore-type */ $this->ruleApplier->apply($rowData, $transformedData, $value, $options));
Loading history...
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30 1
    public function validate(array $options): void
31
    {
32 1
        $this->requireOption('value', $options);
33 1
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38 1
    public function getRuleCode(): string
39
    {
40 1
        return 'str_lower';
41
    }
42
}