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

ConditionProcessorFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 25
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 13 2
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\Core\Core;
17
use Romm\Formz\Form\FormObject;
18
use TYPO3\CMS\Core\SingletonInterface;
19
20
class ConditionProcessorFactory implements SingletonInterface
21
{
22
    /**
23
     * @var ConditionProcessorFactory[]
24
     */
25
    private static $instance;
26
27
    /**
28
     * @param FormObject $formObject
29
     * @return ConditionProcessor
30
     */
31
    public static function get(FormObject $formObject)
32
    {
33
        $hash = $formObject->getHash();
34
35
        if (null === self::$instance[$hash]) {
36
            /** @noinspection PhpMethodParametersCountMismatchInspection */
37
            self::$instance[$hash] = Core::get()
38
                ->getObjectManager()
39
                ->get(ConditionProcessor::class, $formObject);
40
        }
41
42
        return self::$instance[$hash];
43
    }
44
}
45