AbacFactory::setCacheManager()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace PhpAbac;
4
5
use PhpAbac\Configuration\ConfigurationInterface;
6
use PhpAbac\Configuration\Configuration;
7
8
use PhpAbac\Manager\PolicyRuleManager;
9
use PhpAbac\Manager\PolicyRuleManagerInterface;
10
use PhpAbac\Manager\AttributeManager;
11
use PhpAbac\Manager\AttributeManagerInterface;
12
use PhpAbac\Manager\CacheManager;
13
use PhpAbac\Manager\CacheManagerInterface;
14
use PhpAbac\Manager\ComparisonManager;
15
use PhpAbac\Manager\ComparisonManagerInterface;
16
17
18
final class AbacFactory
19
{
20
    /** @var ConfigurationInterface **/
21
    protected static $configuration;
22
    /** @var PolicyRuleManagerInterface **/
23
    protected static $policyRuleManager;
24
    /** @var AttributeManagerInterface **/
25
    protected static $attributeManager;
26
    /** @var CacheManagerInterface **/
27
    protected static $cacheManager;
28
    /** @var ComparisonManagerInterface **/
29
    protected static $comparisonManager;
30
    
31
    public static function setConfiguration(ConfigurationInterface $configuration)
32
    {
33
        self::$configuration = $configuration;
34
    }
35
    
36
    public static function setPolicyRuleManager(PolicyRuleManagerInterface $policyRuleManager)
37
    {
38
        self::$policyRuleManager = $policyRuleManager;
39
    }
40
    
41
    public static function setAttributeManager(AttributeManagerInterface $attributeManager)
42
    {
43
        self::$attributeManager = $attributeManager;
44
    }
45
    
46
    public static function setCacheManager(CacheManagerInterface $cacheManager)
47
    {
48
        self::$cacheManager = $cacheManager;
49
    }
50
    
51
    public static function setComparisonManager(ComparisonManagerInterface $comparisonManager)
52
    {
53
        self::$comparisonManager = $comparisonManager;
54
    }
55
    
56 4
    public static function getAbac(array $configurationFiles, string $configDir = null, array $attributeOptions = [], array $cacheOptions = [])
57
    {
58 4
        $configuration = (self::$configuration !== null) ? self::$configuration : new Configuration($configurationFiles, $configDir);
59 4
        $attributeManager = (self::$attributeManager !== null) ? self::$attributeManager : new AttributeManager($configuration, $attributeOptions);
0 ignored issues
show
Compatibility introduced by
$configuration of type object<PhpAbac\Configura...ConfigurationInterface> is not a sub-type of object<PhpAbac\Configuration\Configuration>. It seems like you assume a concrete implementation of the interface PhpAbac\Configuration\ConfigurationInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
60 4
        $policyRuleManager = (self::$policyRuleManager !== null) ? self::$policyRuleManager : new PolicyRuleManager($configuration, $attributeManager);
0 ignored issues
show
Compatibility introduced by
$configuration of type object<PhpAbac\Configura...ConfigurationInterface> is not a sub-type of object<PhpAbac\Configuration\Configuration>. It seems like you assume a concrete implementation of the interface PhpAbac\Configuration\ConfigurationInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
Compatibility introduced by
$attributeManager of type object<PhpAbac\Manager\AttributeManagerInterface> is not a sub-type of object<PhpAbac\Manager\AttributeManager>. It seems like you assume a concrete implementation of the interface PhpAbac\Manager\AttributeManagerInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
61 4
        $comparisonManager = (self::$comparisonManager !== null) ? self::$comparisonManager : new ComparisonManager($attributeManager);
0 ignored issues
show
Compatibility introduced by
$attributeManager of type object<PhpAbac\Manager\AttributeManagerInterface> is not a sub-type of object<PhpAbac\Manager\AttributeManager>. It seems like you assume a concrete implementation of the interface PhpAbac\Manager\AttributeManagerInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
62 4
        $cacheManager = (self::$cacheManager !== null) ? self::$cacheManager : new CacheManager($cacheOptions);
63
        
64 4
        return new Abac($policyRuleManager, $attributeManager, $comparisonManager, $cacheManager);
0 ignored issues
show
Compatibility introduced by
$policyRuleManager of type object<PhpAbac\Manager\P...cyRuleManagerInterface> is not a sub-type of object<PhpAbac\Manager\PolicyRuleManager>. It seems like you assume a concrete implementation of the interface PhpAbac\Manager\PolicyRuleManagerInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
Compatibility introduced by
$attributeManager of type object<PhpAbac\Manager\AttributeManagerInterface> is not a sub-type of object<PhpAbac\Manager\AttributeManager>. It seems like you assume a concrete implementation of the interface PhpAbac\Manager\AttributeManagerInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
Compatibility introduced by
$comparisonManager of type object<PhpAbac\Manager\C...arisonManagerInterface> is not a sub-type of object<PhpAbac\Manager\ComparisonManager>. It seems like you assume a concrete implementation of the interface PhpAbac\Manager\ComparisonManagerInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
Compatibility introduced by
$cacheManager of type object<PhpAbac\Manager\CacheManagerInterface> is not a sub-type of object<PhpAbac\Manager\CacheManager>. It seems like you assume a concrete implementation of the interface PhpAbac\Manager\CacheManagerInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
65
    }
66
}