Completed
Branch conditions-refactoring (4b1dba)
by Romain
03:17
created

ConditionProcessor   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 55
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getActivationConditionTreeForField() 0 6 1
A getActivationConditionTreeForValidation() 0 6 1
A getFormObject() 0 4 1
1
<?php
2
/*
3
 * 2016 Romain CANON <[email protected]>
4
 *
5
 * This file is part of the TYPO3 Formz project.
6
 * It is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License, either
8
 * version 3 of the License, or any later version.
9
 *
10
 * For the full copyright and license information, see:
11
 * http://www.gnu.org/licenses/gpl-3.0.html
12
 */
13
14
namespace Romm\Formz\Condition\Processor;
15
16
use Romm\Formz\Condition\ConditionTree;
17
use Romm\Formz\Condition\Parser\ConditionParserFactory;
18
use Romm\Formz\Configuration\Form\Field\Field;
19
use Romm\Formz\Configuration\Form\Field\Validation\Validation;
20
use Romm\Formz\Configuration\Form\Form;
21
use Romm\Formz\Form\FormObject;
22
23
class ConditionProcessor
24
{
25
    /**
26
     * @var FormObject
27
     */
28
    private $formObject;
29
30
    /**
31
     * @var Form
32
     */
33
    private $formConfiguration;
34
35
    /**
36
     * @param FormObject $formObject
37
     */
38
    public function __construct(FormObject $formObject)
39
    {
40
        $this->formObject = $formObject;
41
        $this->formConfiguration = $this->formObject->getConfiguration();;
42
    }
43
44
    /**
45
     * @todo
46
     *
47
     * @param Field $field
48
     * @return ConditionTree
49
     */
50
    public function getActivationConditionTreeForField(Field $field)
51
    {
52
        return ConditionParserFactory::get($this->formObject)
53
            ->parse($field->getActivation())
54
            ->attachConditionProcessor($this);
55
    }
56
57
    /**
58
     * @todo
59
     *
60
     * @param Validation $validation
61
     * @return ConditionTree
62
     */
63
    public function getActivationConditionTreeForValidation(Validation $validation)
64
    {
65
        return ConditionParserFactory::get($this->formObject)
66
            ->parse($validation->getActivation())
67
            ->attachConditionProcessor($this);
68
    }
69
70
    /**
71
     * @return FormObject
72
     */
73
    public function getFormObject()
74
    {
75
        return $this->formObject;
76
    }
77
}
78