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

Constant::validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
}