Completed
Push — master ( 610136...82575c )
by De Cramer
06:15 queued 03:00
created

Constant   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 33
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 3 1
A getRuleCode() 0 3 1
A validate() 0 3 1
1
<?php
2
3
namespace Oliverde8\Component\RuleEngine\Rules;
4
5
/**
6
 * Class Constant
7
 *
8
 * @author    de Cramer Oliver<[email protected]>
9
 * @copyright 2018 Oliverde8
10
 * @package Oliverde8\Component\RuleEngine\Rules
11
 */
12
class Constant extends AbstractRule
13
{
14
15
    /**
16
     * Apply a certain rule and returns the result.
17
     *
18
     * @param array $rowData Data that is being trasformed.
19
     * @param array $transformedData Transformed data at the current stage
20
     * @param array $options Options to be used by the rule.
21
     *
22
     * @return string|null
23
     */
24 1
    public function apply($rowData, &$transformedData, $options = [])
25
    {
26 1
        return $options['value'];
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32 1
    public function validate($options)
33
    {
34 1
        $this->requireOption('value', $options);
35 1
    }
36
37
    /**
38
     * Get unique code that needs to be used to apply this rule.
39
     *
40
     * @return string
41
     */
42 1
    public function getRuleCode()
43
    {
44 1
        return 'constant';
45
    }
46
}