Constant::validate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
ccs 0
cts 0
cp 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Oliverde8\Component\RuleEngine\Rules;
6
7
use Oliverde8\Component\RuleEngine\Exceptions\RuleException;
8
9
/**
10
 * Class Constant
11
 *
12
 * @author    de Cramer Oliver<[email protected]>
13
 * @copyright 2018 Oliverde8
14
 * @package Oliverde8\Component\RuleEngine\Rules
15
 */
16
class Constant extends AbstractRule
17
{
18
19
    /**
20
     * Apply a certain rule and returns the result.
21
     *
22
     * @param array $rowData Data that is being trasformed.
23
     * @param array $transformedData Transformed data at the current stage
24 1
     * @param array $options Options to be used by the rule.
25
     *
26 1
     * @return string|null
27
     */
28
    public function apply(array $rowData, array &$transformedData, array $options = [])
29
    {
30
        return $options['value'];
31
    }
32 1
33
    /**
34 1
     * @inheritdoc
35 1
     */
36
    public function validate($options): void
37
    {
38
        $this->requireOption('value', $options);
39
    }
40
41
    /**
42 1
     * Get unique code that needs to be used to apply this rule.
43
     *
44 1
     * @return string
45
     */
46
    public function getRuleCode(): string
47
    {
48
        return 'constant';
49
    }
50
}