@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | * {@inheritdoc} |
17 | 17 | */ |
18 | 18 | public function deleteItem($key) { |
19 | - if(isset($this->items[$key])) { |
|
19 | + if (isset($this->items[$key])) { |
|
20 | 20 | unset($this->items[$key]); |
21 | 21 | } |
22 | - if(isset($this->deferredItems[$key])) { |
|
22 | + if (isset($this->deferredItems[$key])) { |
|
23 | 23 | unset($this->deferredItems[$key]); |
24 | 24 | } |
25 | 25 | return true; |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * {@inheritdoc} |
30 | 30 | */ |
31 | 31 | public function deleteItems(array $keys) { |
32 | - foreach($keys as $key) { |
|
33 | - if(!$this->deleteItem($key)) { |
|
32 | + foreach ($keys as $key) { |
|
33 | + if (!$this->deleteItem($key)) { |
|
34 | 34 | return false; |
35 | 35 | } |
36 | 36 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * {@inheritdoc} |
60 | 60 | */ |
61 | 61 | public function commit() { |
62 | - foreach($this->deferredItems as $key => $item) { |
|
62 | + foreach ($this->deferredItems as $key => $item) { |
|
63 | 63 | $this->items[$key] = $item; |
64 | 64 | unset($this->deferredItems[$key]); |
65 | 65 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * {@inheritdoc} |
78 | 78 | */ |
79 | 79 | public function getItem($key) { |
80 | - if(!$this->hasItem($key)) { |
|
80 | + if (!$this->hasItem($key)) { |
|
81 | 81 | return new MemoryCacheItem($key); |
82 | 82 | } |
83 | 83 | return $this->items[$key]; |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function getItems(array $keys = array()) { |
90 | 90 | $items = []; |
91 | - foreach($keys as $key) { |
|
92 | - if($this->hasItem($key)) { |
|
91 | + foreach ($keys as $key) { |
|
92 | + if ($this->hasItem($key)) { |
|
93 | 93 | $items[$key] = $this->getItem($key); |
94 | 94 | } |
95 | 95 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | * {@inheritdoc} |
54 | 54 | */ |
55 | 55 | public function get() { |
56 | - if(!$this->isHit()) { |
|
56 | + if (!$this->isHit()) { |
|
57 | 57 | throw new ExpiredCacheException('Cache item is expired'); |
58 | 58 | } |
59 | 59 | return $this->value; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $item = $pool->getItem($key); |
31 | 31 | |
32 | 32 | // In this case, the pool returned a new CacheItem |
33 | - if($item->get() === null) { |
|
33 | + if ($item->get() === null) { |
|
34 | 34 | $item->expiresAfter($ttl); |
35 | 35 | } |
36 | 36 | return $item; |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @return Psr\Cache\CacheItemPoolInterface |
43 | 43 | */ |
44 | 44 | public function getItemPool($driver) { |
45 | - if(!isset($this->pools[$driver])) { |
|
46 | - $poolClass = 'PhpAbac\\Cache\\Pool\\' . ucfirst($driver) . 'CacheItemPool'; |
|
45 | + if (!isset($this->pools[$driver])) { |
|
46 | + $poolClass = 'PhpAbac\\Cache\\Pool\\'.ucfirst($driver).'CacheItemPool'; |
|
47 | 47 | $this->pools[$driver] = new $poolClass(); |
48 | 48 | } |
49 | 49 | return $this->pools[$driver]; |
@@ -69,7 +69,6 @@ discard block |
||
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @param AbstractAttribute $attribute |
72 | - * @param string $attributeType |
|
73 | 72 | * @param object $user |
74 | 73 | * @param object $object |
75 | 74 | * @return mixed |
@@ -108,7 +107,7 @@ discard block |
||
108 | 107 | /** |
109 | 108 | * |
110 | 109 | * @param \PhpAbac\Model\EnvironmentAttribute $attribute |
111 | - * @return mixed |
|
110 | + * @return string |
|
112 | 111 | */ |
113 | 112 | private function retrieveEnvironmentAttribute(EnvironmentAttribute $attribute) { |
114 | 113 | return getenv($attribute->getVariableName()); |
@@ -19,23 +19,23 @@ discard block |
||
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @param array $attributes |
22 | - * @param array $options A List of option to configure This Abac Instance |
|
23 | - * Options list : |
|
24 | - * 'getter_prefix' => Prefix to add before getter name (default)'get' |
|
25 | - * 'getter_name_transformation_function' => Function to apply on the getter name ( before adding prefix ) (default)'ucfirst' |
|
22 | + * @param array $options A List of option to configure This Abac Instance |
|
23 | + * Options list : |
|
24 | + * 'getter_prefix' => Prefix to add before getter name (default)'get' |
|
25 | + * 'getter_name_transformation_function' => Function to apply on the getter name ( before adding prefix ) (default)'ucfirst' |
|
26 | 26 | */ |
27 | 27 | public function __construct($attributes, $options = []) |
28 | 28 | { |
29 | 29 | $this->attributes = $attributes; |
30 | 30 | |
31 | - $options = array_intersect_key( $options, array_flip( [ |
|
32 | - 'getter_prefix', |
|
33 | - 'getter_name_transformation_function', |
|
34 | - ] ) ); |
|
31 | + $options = array_intersect_key( $options, array_flip( [ |
|
32 | + 'getter_prefix', |
|
33 | + 'getter_name_transformation_function', |
|
34 | + ] ) ); |
|
35 | 35 | |
36 | - foreach($options as $name => $value) { |
|
37 | - $this->$name = $value; |
|
38 | - } |
|
36 | + foreach($options as $name => $value) { |
|
37 | + $this->$name = $value; |
|
38 | + } |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | foreach($propertyPath as $property) { |
118 | 118 | |
119 | 119 | |
120 | - $getter = $this->getter_prefix.call_user_func($this->getter_name_transformation_function,$property); |
|
120 | + $getter = $this->getter_prefix.call_user_func($this->getter_name_transformation_function,$property); |
|
121 | 121 | // Use is_callable, instead of method_exists, to deal with __call magic method |
122 | 122 | if(!is_callable([$propertyValue,$getter])) { |
123 | 123 | throw new \InvalidArgumentException('There is no getter for the "'.$attribute->getProperty().'" attribute for object "'.get_class($propertyValue).'" with getter "'.$getter.'"'); |
124 | 124 | } |
125 | - if ( ( $propertyValue = call_user_func_array( [ |
|
126 | - $propertyValue, |
|
127 | - $getter, |
|
128 | - ], isset( $getter_params[ $property ] ) ? $getter_params[ $property ] : [] ) ) === null |
|
129 | - ) { |
|
130 | - return null; |
|
131 | - } |
|
125 | + if ( ( $propertyValue = call_user_func_array( [ |
|
126 | + $propertyValue, |
|
127 | + $getter, |
|
128 | + ], isset( $getter_params[ $property ] ) ? $getter_params[ $property ] : [] ) ) === null |
|
129 | + ) { |
|
130 | + return null; |
|
131 | + } |
|
132 | 132 | } |
133 | 133 | return $propertyValue; |
134 | 134 | } |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | { |
29 | 29 | $this->attributes = $attributes; |
30 | 30 | |
31 | - $options = array_intersect_key( $options, array_flip( [ |
|
31 | + $options = array_intersect_key($options, array_flip([ |
|
32 | 32 | 'getter_prefix', |
33 | 33 | 'getter_name_transformation_function', |
34 | - ] ) ); |
|
34 | + ])); |
|
35 | 35 | |
36 | - foreach($options as $name => $value) { |
|
36 | + foreach ($options as $name => $value) { |
|
37 | 37 | $this->$name = $value; |
38 | 38 | } |
39 | 39 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function retrieveAttribute(AbstractAttribute $attribute, $user = null, $object = null, $getter_params = []) |
97 | 97 | { |
98 | - switch($attribute->getType()) { |
|
98 | + switch ($attribute->getType()) { |
|
99 | 99 | case 'user': |
100 | 100 | return $this->retrieveClassicAttribute($attribute, $user, $getter_params); |
101 | 101 | case 'resource': |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | { |
115 | 115 | $propertyPath = explode('.', $attribute->getProperty()); |
116 | 116 | $propertyValue = $object; |
117 | - foreach($propertyPath as $property) { |
|
117 | + foreach ($propertyPath as $property) { |
|
118 | 118 | |
119 | 119 | |
120 | - $getter = $this->getter_prefix.call_user_func($this->getter_name_transformation_function,$property); |
|
120 | + $getter = $this->getter_prefix.call_user_func($this->getter_name_transformation_function, $property); |
|
121 | 121 | // Use is_callable, instead of method_exists, to deal with __call magic method |
122 | - if(!is_callable([$propertyValue,$getter])) { |
|
122 | + if (!is_callable([$propertyValue, $getter])) { |
|
123 | 123 | throw new \InvalidArgumentException('There is no getter for the "'.$attribute->getProperty().'" attribute for object "'.get_class($propertyValue).'" with getter "'.$getter.'"'); |
124 | 124 | } |
125 | - if ( ( $propertyValue = call_user_func_array( [ |
|
125 | + if (($propertyValue = call_user_func_array([ |
|
126 | 126 | $propertyValue, |
127 | 127 | $getter, |
128 | - ], isset( $getter_params[ $property ] ) ? $getter_params[ $property ] : [] ) ) === null |
|
128 | + ], isset($getter_params[$property]) ? $getter_params[$property] : [])) === null |
|
129 | 129 | ) { |
130 | 130 | return null; |
131 | 131 | } |
@@ -7,9 +7,7 @@ |
||
7 | 7 | use PhpAbac\Manager\ConfigurationManager; |
8 | 8 | use PhpAbac\Manager\CacheManager; |
9 | 9 | use PhpAbac\Manager\ComparisonManager; |
10 | - |
|
11 | 10 | use Symfony\Component\Config\FileLocator; |
12 | - |
|
13 | 11 | use PhpAbac\Model\PolicyRuleAttribute; |
14 | 12 | |
15 | 13 | class Abac |
@@ -13,165 +13,165 @@ |
||
13 | 13 | use PhpAbac\Model\PolicyRuleAttribute; |
14 | 14 | |
15 | 15 | class Abac { |
16 | - /** @var \PhpAbac\Manager\ConfigurationManager * */ |
|
17 | - private $configuration; |
|
18 | - /** @var \PhpAbac\Manager\PolicyRuleManager * */ |
|
19 | - private $policyRuleManager; |
|
20 | - /** @var \PhpAbac\Manager\AttributeManager * */ |
|
21 | - private $attributeManager; |
|
22 | - /** @var \PhpAbac\Manager\CacheManager * */ |
|
23 | - private $cacheManager; |
|
24 | - /** @var \PhpAbac\Manager\ComparisonManager * */ |
|
25 | - private $comparisonManager; |
|
16 | + /** @var \PhpAbac\Manager\ConfigurationManager * */ |
|
17 | + private $configuration; |
|
18 | + /** @var \PhpAbac\Manager\PolicyRuleManager * */ |
|
19 | + private $policyRuleManager; |
|
20 | + /** @var \PhpAbac\Manager\AttributeManager * */ |
|
21 | + private $attributeManager; |
|
22 | + /** @var \PhpAbac\Manager\CacheManager * */ |
|
23 | + private $cacheManager; |
|
24 | + /** @var \PhpAbac\Manager\ComparisonManager * */ |
|
25 | + private $comparisonManager; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @param array $configPaths |
|
29 | - * @param array $cacheOptions Option for cache |
|
30 | - * @param string $configPaths_root The origin folder to find $configPaths |
|
31 | - * @param array $options |
|
32 | - */ |
|
33 | - public function __construct( $configPaths, $cacheOptions = [], $configPaths_root = null, $options = [] ) { |
|
34 | - $this->configure( $configPaths, $configPaths_root ); |
|
35 | - $this->attributeManager = new AttributeManager( $this->configuration->getAttributes(), $options ); |
|
36 | - $this->policyRuleManager = new PolicyRuleManager( $this->attributeManager, $this->configuration->getRules() ); |
|
37 | - $this->cacheManager = new CacheManager( $cacheOptions ); |
|
38 | - $this->comparisonManager = new ComparisonManager( $this->attributeManager ); |
|
39 | - } |
|
27 | + /** |
|
28 | + * @param array $configPaths |
|
29 | + * @param array $cacheOptions Option for cache |
|
30 | + * @param string $configPaths_root The origin folder to find $configPaths |
|
31 | + * @param array $options |
|
32 | + */ |
|
33 | + public function __construct( $configPaths, $cacheOptions = [], $configPaths_root = null, $options = [] ) { |
|
34 | + $this->configure( $configPaths, $configPaths_root ); |
|
35 | + $this->attributeManager = new AttributeManager( $this->configuration->getAttributes(), $options ); |
|
36 | + $this->policyRuleManager = new PolicyRuleManager( $this->attributeManager, $this->configuration->getRules() ); |
|
37 | + $this->cacheManager = new CacheManager( $cacheOptions ); |
|
38 | + $this->comparisonManager = new ComparisonManager( $this->attributeManager ); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param array $configPaths |
|
43 | - * @param string $configPaths_root The origin folder to find $configPaths |
|
44 | - */ |
|
45 | - public function configure( $configPaths, $configPaths_root = null ) { |
|
41 | + /** |
|
42 | + * @param array $configPaths |
|
43 | + * @param string $configPaths_root The origin folder to find $configPaths |
|
44 | + */ |
|
45 | + public function configure( $configPaths, $configPaths_root = null ) { |
|
46 | 46 | // foreach ( $configPaths as &$configPath ) { |
47 | 47 | // $configPath = $configPaths_root . $configPath; |
48 | 48 | // } |
49 | - $locator = new FileLocator( $configPaths_root ); |
|
50 | - $this->configuration = new ConfigurationManager( $locator ); |
|
51 | - $this->configuration->setConfigPathRoot( $configPaths_root ); |
|
52 | - $this->configuration->parseConfigurationFile( $configPaths ); |
|
53 | - } |
|
49 | + $locator = new FileLocator( $configPaths_root ); |
|
50 | + $this->configuration = new ConfigurationManager( $locator ); |
|
51 | + $this->configuration->setConfigPathRoot( $configPaths_root ); |
|
52 | + $this->configuration->parseConfigurationFile( $configPaths ); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Return true if both user and object respects all the rules conditions |
|
57 | - * If the objectId is null, policy rules about its attributes will be ignored |
|
58 | - * In case of mismatch between attributes and expected values, |
|
59 | - * an array with the concerned attributes slugs will be returned. |
|
60 | - * |
|
61 | - * Available options are : |
|
62 | - * * dynamic_attributes: array |
|
63 | - * * cache_result: boolean |
|
64 | - * * cache_ttl: integer |
|
65 | - * * cache_driver: string |
|
66 | - * |
|
67 | - * Available cache drivers are : |
|
68 | - * * memory |
|
69 | - * |
|
70 | - * @param string $ruleName |
|
71 | - * @param object $user |
|
72 | - * @param object $resource |
|
73 | - * @param array $options |
|
74 | - * |
|
75 | - * @return boolean|array |
|
76 | - */ |
|
77 | - public function enforce( $ruleName, $user, $resource = null, $options = [] ) { |
|
78 | - // If there is dynamic attributes, we pass them to the comparison manager |
|
79 | - // When a comparison will be performed, the passed values will be retrieved and used |
|
80 | - if ( isset( $options[ 'dynamic_attributes' ] ) ) { |
|
81 | - $this->comparisonManager->setDynamicAttributes( $options[ 'dynamic_attributes' ] ); |
|
82 | - } |
|
83 | - // Retrieve cache value for the current rule and values if cache item is valid |
|
84 | - if ( ( $cacheResult = isset( $options[ 'cache_result' ] ) && $options[ 'cache_result' ] === true ) === true ) { |
|
85 | - $cacheItem = $this->cacheManager->getItem( "$ruleName-{$user->getId()}-" . ( ( $resource !== null ) ? $resource->getId() : '' ), ( isset( $options[ 'cache_driver' ] ) ) ? $options[ 'cache_driver' ] : null, ( isset( $options[ 'cache_ttl' ] ) ) ? $options[ 'cache_ttl' ] : null ); |
|
86 | - // We check if the cache value s valid before returning it |
|
87 | - if ( ( $cacheValue = $cacheItem->get() ) !== null ) { |
|
88 | - return $cacheValue; |
|
89 | - } |
|
90 | - } |
|
91 | - $policyRule_a = $this->policyRuleManager->getRule( $ruleName, $user, $resource ); |
|
55 | + /** |
|
56 | + * Return true if both user and object respects all the rules conditions |
|
57 | + * If the objectId is null, policy rules about its attributes will be ignored |
|
58 | + * In case of mismatch between attributes and expected values, |
|
59 | + * an array with the concerned attributes slugs will be returned. |
|
60 | + * |
|
61 | + * Available options are : |
|
62 | + * * dynamic_attributes: array |
|
63 | + * * cache_result: boolean |
|
64 | + * * cache_ttl: integer |
|
65 | + * * cache_driver: string |
|
66 | + * |
|
67 | + * Available cache drivers are : |
|
68 | + * * memory |
|
69 | + * |
|
70 | + * @param string $ruleName |
|
71 | + * @param object $user |
|
72 | + * @param object $resource |
|
73 | + * @param array $options |
|
74 | + * |
|
75 | + * @return boolean|array |
|
76 | + */ |
|
77 | + public function enforce( $ruleName, $user, $resource = null, $options = [] ) { |
|
78 | + // If there is dynamic attributes, we pass them to the comparison manager |
|
79 | + // When a comparison will be performed, the passed values will be retrieved and used |
|
80 | + if ( isset( $options[ 'dynamic_attributes' ] ) ) { |
|
81 | + $this->comparisonManager->setDynamicAttributes( $options[ 'dynamic_attributes' ] ); |
|
82 | + } |
|
83 | + // Retrieve cache value for the current rule and values if cache item is valid |
|
84 | + if ( ( $cacheResult = isset( $options[ 'cache_result' ] ) && $options[ 'cache_result' ] === true ) === true ) { |
|
85 | + $cacheItem = $this->cacheManager->getItem( "$ruleName-{$user->getId()}-" . ( ( $resource !== null ) ? $resource->getId() : '' ), ( isset( $options[ 'cache_driver' ] ) ) ? $options[ 'cache_driver' ] : null, ( isset( $options[ 'cache_ttl' ] ) ) ? $options[ 'cache_ttl' ] : null ); |
|
86 | + // We check if the cache value s valid before returning it |
|
87 | + if ( ( $cacheValue = $cacheItem->get() ) !== null ) { |
|
88 | + return $cacheValue; |
|
89 | + } |
|
90 | + } |
|
91 | + $policyRule_a = $this->policyRuleManager->getRule( $ruleName, $user, $resource ); |
|
92 | 92 | |
93 | - foreach ( $policyRule_a as $policyRule ) { |
|
94 | - // For each policy rule attribute, we retrieve the attribute value and proceed configured extra data |
|
95 | - foreach ( $policyRule->getPolicyRuleAttributes() as $pra ) { |
|
96 | - /** @var PolicyRuleAttribute $pra */ |
|
97 | - $attribute = $pra->getAttribute(); |
|
93 | + foreach ( $policyRule_a as $policyRule ) { |
|
94 | + // For each policy rule attribute, we retrieve the attribute value and proceed configured extra data |
|
95 | + foreach ( $policyRule->getPolicyRuleAttributes() as $pra ) { |
|
96 | + /** @var PolicyRuleAttribute $pra */ |
|
97 | + $attribute = $pra->getAttribute(); |
|
98 | 98 | |
99 | - $getter_params = $this->prepareGetterParams($pra->getGetterParams(), $user, $resource); |
|
99 | + $getter_params = $this->prepareGetterParams($pra->getGetterParams(), $user, $resource); |
|
100 | 100 | // var_dump($pra->getGetterParams()); |
101 | 101 | // var_dump($getter_params); |
102 | - $attribute->setValue( $this->attributeManager->retrieveAttribute( $attribute, $user, $resource, $getter_params ) ); |
|
103 | - if ( count( $pra->getExtraData() ) > 0 ) { |
|
104 | - $this->processExtraData( $pra, $user, $resource ); |
|
105 | - } |
|
106 | - $this->comparisonManager->compare( $pra ); |
|
107 | - } |
|
108 | - // The given result could be an array of rejected attributes or true |
|
109 | - // True means that the rule is correctly enforced for the given user and resource |
|
110 | - $result = $this->comparisonManager->getResult(); |
|
111 | - if ( true === $result ) { |
|
112 | - break; |
|
113 | - } |
|
114 | - } |
|
115 | - if ( $cacheResult ) { |
|
116 | - $cacheItem->set( $result ); |
|
117 | - $this->cacheManager->save( $cacheItem ); |
|
118 | - } |
|
102 | + $attribute->setValue( $this->attributeManager->retrieveAttribute( $attribute, $user, $resource, $getter_params ) ); |
|
103 | + if ( count( $pra->getExtraData() ) > 0 ) { |
|
104 | + $this->processExtraData( $pra, $user, $resource ); |
|
105 | + } |
|
106 | + $this->comparisonManager->compare( $pra ); |
|
107 | + } |
|
108 | + // The given result could be an array of rejected attributes or true |
|
109 | + // True means that the rule is correctly enforced for the given user and resource |
|
110 | + $result = $this->comparisonManager->getResult(); |
|
111 | + if ( true === $result ) { |
|
112 | + break; |
|
113 | + } |
|
114 | + } |
|
115 | + if ( $cacheResult ) { |
|
116 | + $cacheItem->set( $result ); |
|
117 | + $this->cacheManager->save( $cacheItem ); |
|
118 | + } |
|
119 | 119 | |
120 | - return $result; |
|
121 | - } |
|
120 | + return $result; |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Function to prepare Getter Params when getter require parameters ( this parameters must be specified in configuration file) |
|
125 | - * |
|
126 | - * @param $getter_params |
|
127 | - * @param $user |
|
128 | - * @param $resource |
|
129 | - * |
|
130 | - * @return array |
|
131 | - */ |
|
132 | - private function prepareGetterParams($getter_params, $user, $resource) { |
|
133 | - if (empty($getter_params)) return []; |
|
134 | - $values = []; |
|
135 | - foreach($getter_params as $getter_name=>$params) { |
|
136 | - foreach($params as $param) { |
|
137 | - if ( '@' !== $param[ 'param_name' ][ 0 ] ) { |
|
138 | - $values[$getter_name][] = $param[ 'param_value' ]; |
|
139 | - } |
|
140 | - else { |
|
141 | - $values[$getter_name][] = $this->attributeManager->retrieveAttribute( $this->attributeManager->getAttribute( $param[ 'param_value' ] ) , $user, $resource ); |
|
142 | - } |
|
143 | - } |
|
144 | - } |
|
145 | - return $values; |
|
146 | - } |
|
123 | + /** |
|
124 | + * Function to prepare Getter Params when getter require parameters ( this parameters must be specified in configuration file) |
|
125 | + * |
|
126 | + * @param $getter_params |
|
127 | + * @param $user |
|
128 | + * @param $resource |
|
129 | + * |
|
130 | + * @return array |
|
131 | + */ |
|
132 | + private function prepareGetterParams($getter_params, $user, $resource) { |
|
133 | + if (empty($getter_params)) return []; |
|
134 | + $values = []; |
|
135 | + foreach($getter_params as $getter_name=>$params) { |
|
136 | + foreach($params as $param) { |
|
137 | + if ( '@' !== $param[ 'param_name' ][ 0 ] ) { |
|
138 | + $values[$getter_name][] = $param[ 'param_value' ]; |
|
139 | + } |
|
140 | + else { |
|
141 | + $values[$getter_name][] = $this->attributeManager->retrieveAttribute( $this->attributeManager->getAttribute( $param[ 'param_value' ] ) , $user, $resource ); |
|
142 | + } |
|
143 | + } |
|
144 | + } |
|
145 | + return $values; |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * @param \PhpAbac\Model\PolicyRuleAttribute $pra |
|
150 | - * @param object $user |
|
151 | - * @param object $resource |
|
152 | - */ |
|
153 | - public function processExtraData( PolicyRuleAttribute $pra, $user, $resource ) { |
|
154 | - foreach ( $pra->getExtraData() as $key => $data ) { |
|
155 | - switch ( $key ) { |
|
156 | - case 'with': |
|
157 | - // This data has to be removed for it will be stored elsewhere |
|
158 | - // in the policy rule attribute |
|
159 | - $pra->removeExtraData( 'with' ); |
|
160 | - // The "with" extra data is an array of attributes, which are objects |
|
161 | - // Once we process it as policy rule attributes, we set it as the main policy rule attribute value |
|
162 | - $subPolicyRuleAttributes = []; |
|
163 | - $extraData = []; |
|
148 | + /** |
|
149 | + * @param \PhpAbac\Model\PolicyRuleAttribute $pra |
|
150 | + * @param object $user |
|
151 | + * @param object $resource |
|
152 | + */ |
|
153 | + public function processExtraData( PolicyRuleAttribute $pra, $user, $resource ) { |
|
154 | + foreach ( $pra->getExtraData() as $key => $data ) { |
|
155 | + switch ( $key ) { |
|
156 | + case 'with': |
|
157 | + // This data has to be removed for it will be stored elsewhere |
|
158 | + // in the policy rule attribute |
|
159 | + $pra->removeExtraData( 'with' ); |
|
160 | + // The "with" extra data is an array of attributes, which are objects |
|
161 | + // Once we process it as policy rule attributes, we set it as the main policy rule attribute value |
|
162 | + $subPolicyRuleAttributes = []; |
|
163 | + $extraData = []; |
|
164 | 164 | |
165 | - foreach ( $this->policyRuleManager->processRuleAttributes( $data, $user, $resource ) as $subPolicyRuleAttribute ) { |
|
166 | - $subPolicyRuleAttributes[] = $subPolicyRuleAttribute; |
|
167 | - } |
|
168 | - $pra->setValue( $subPolicyRuleAttributes ); |
|
169 | - // This data can be used in complex comparisons |
|
170 | - $pra->addExtraData( 'attribute', $pra->getAttribute() ); |
|
171 | - $pra->addExtraData( 'user', $user ); |
|
172 | - $pra->addExtraData( 'resource', $resource ); |
|
173 | - break; |
|
174 | - } |
|
175 | - } |
|
176 | - } |
|
165 | + foreach ( $this->policyRuleManager->processRuleAttributes( $data, $user, $resource ) as $subPolicyRuleAttribute ) { |
|
166 | + $subPolicyRuleAttributes[] = $subPolicyRuleAttribute; |
|
167 | + } |
|
168 | + $pra->setValue( $subPolicyRuleAttributes ); |
|
169 | + // This data can be used in complex comparisons |
|
170 | + $pra->addExtraData( 'attribute', $pra->getAttribute() ); |
|
171 | + $pra->addExtraData( 'user', $user ); |
|
172 | + $pra->addExtraData( 'resource', $resource ); |
|
173 | + break; |
|
174 | + } |
|
175 | + } |
|
176 | + } |
|
177 | 177 | } |
@@ -30,26 +30,26 @@ discard block |
||
30 | 30 | * @param string $configPaths_root The origin folder to find $configPaths |
31 | 31 | * @param array $options |
32 | 32 | */ |
33 | - public function __construct( $configPaths, $cacheOptions = [], $configPaths_root = null, $options = [] ) { |
|
34 | - $this->configure( $configPaths, $configPaths_root ); |
|
35 | - $this->attributeManager = new AttributeManager( $this->configuration->getAttributes(), $options ); |
|
36 | - $this->policyRuleManager = new PolicyRuleManager( $this->attributeManager, $this->configuration->getRules() ); |
|
37 | - $this->cacheManager = new CacheManager( $cacheOptions ); |
|
38 | - $this->comparisonManager = new ComparisonManager( $this->attributeManager ); |
|
33 | + public function __construct($configPaths, $cacheOptions = [], $configPaths_root = null, $options = []) { |
|
34 | + $this->configure($configPaths, $configPaths_root); |
|
35 | + $this->attributeManager = new AttributeManager($this->configuration->getAttributes(), $options); |
|
36 | + $this->policyRuleManager = new PolicyRuleManager($this->attributeManager, $this->configuration->getRules()); |
|
37 | + $this->cacheManager = new CacheManager($cacheOptions); |
|
38 | + $this->comparisonManager = new ComparisonManager($this->attributeManager); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @param array $configPaths |
43 | 43 | * @param string $configPaths_root The origin folder to find $configPaths |
44 | 44 | */ |
45 | - public function configure( $configPaths, $configPaths_root = null ) { |
|
45 | + public function configure($configPaths, $configPaths_root = null) { |
|
46 | 46 | // foreach ( $configPaths as &$configPath ) { |
47 | 47 | // $configPath = $configPaths_root . $configPath; |
48 | 48 | // } |
49 | - $locator = new FileLocator( $configPaths_root ); |
|
50 | - $this->configuration = new ConfigurationManager( $locator ); |
|
51 | - $this->configuration->setConfigPathRoot( $configPaths_root ); |
|
52 | - $this->configuration->parseConfigurationFile( $configPaths ); |
|
49 | + $locator = new FileLocator($configPaths_root); |
|
50 | + $this->configuration = new ConfigurationManager($locator); |
|
51 | + $this->configuration->setConfigPathRoot($configPaths_root); |
|
52 | + $this->configuration->parseConfigurationFile($configPaths); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -74,47 +74,47 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return boolean|array |
76 | 76 | */ |
77 | - public function enforce( $ruleName, $user, $resource = null, $options = [] ) { |
|
77 | + public function enforce($ruleName, $user, $resource = null, $options = []) { |
|
78 | 78 | // If there is dynamic attributes, we pass them to the comparison manager |
79 | 79 | // When a comparison will be performed, the passed values will be retrieved and used |
80 | - if ( isset( $options[ 'dynamic_attributes' ] ) ) { |
|
81 | - $this->comparisonManager->setDynamicAttributes( $options[ 'dynamic_attributes' ] ); |
|
80 | + if (isset($options['dynamic_attributes'])) { |
|
81 | + $this->comparisonManager->setDynamicAttributes($options['dynamic_attributes']); |
|
82 | 82 | } |
83 | 83 | // Retrieve cache value for the current rule and values if cache item is valid |
84 | - if ( ( $cacheResult = isset( $options[ 'cache_result' ] ) && $options[ 'cache_result' ] === true ) === true ) { |
|
85 | - $cacheItem = $this->cacheManager->getItem( "$ruleName-{$user->getId()}-" . ( ( $resource !== null ) ? $resource->getId() : '' ), ( isset( $options[ 'cache_driver' ] ) ) ? $options[ 'cache_driver' ] : null, ( isset( $options[ 'cache_ttl' ] ) ) ? $options[ 'cache_ttl' ] : null ); |
|
84 | + if (($cacheResult = isset($options['cache_result']) && $options['cache_result'] === true) === true) { |
|
85 | + $cacheItem = $this->cacheManager->getItem("$ruleName-{$user->getId()}-".(($resource !== null) ? $resource->getId() : ''), (isset($options['cache_driver'])) ? $options['cache_driver'] : null, (isset($options['cache_ttl'])) ? $options['cache_ttl'] : null); |
|
86 | 86 | // We check if the cache value s valid before returning it |
87 | - if ( ( $cacheValue = $cacheItem->get() ) !== null ) { |
|
87 | + if (($cacheValue = $cacheItem->get()) !== null) { |
|
88 | 88 | return $cacheValue; |
89 | 89 | } |
90 | 90 | } |
91 | - $policyRule_a = $this->policyRuleManager->getRule( $ruleName, $user, $resource ); |
|
91 | + $policyRule_a = $this->policyRuleManager->getRule($ruleName, $user, $resource); |
|
92 | 92 | |
93 | - foreach ( $policyRule_a as $policyRule ) { |
|
93 | + foreach ($policyRule_a as $policyRule) { |
|
94 | 94 | // For each policy rule attribute, we retrieve the attribute value and proceed configured extra data |
95 | - foreach ( $policyRule->getPolicyRuleAttributes() as $pra ) { |
|
95 | + foreach ($policyRule->getPolicyRuleAttributes() as $pra) { |
|
96 | 96 | /** @var PolicyRuleAttribute $pra */ |
97 | 97 | $attribute = $pra->getAttribute(); |
98 | 98 | |
99 | 99 | $getter_params = $this->prepareGetterParams($pra->getGetterParams(), $user, $resource); |
100 | 100 | // var_dump($pra->getGetterParams()); |
101 | 101 | // var_dump($getter_params); |
102 | - $attribute->setValue( $this->attributeManager->retrieveAttribute( $attribute, $user, $resource, $getter_params ) ); |
|
103 | - if ( count( $pra->getExtraData() ) > 0 ) { |
|
104 | - $this->processExtraData( $pra, $user, $resource ); |
|
102 | + $attribute->setValue($this->attributeManager->retrieveAttribute($attribute, $user, $resource, $getter_params)); |
|
103 | + if (count($pra->getExtraData()) > 0) { |
|
104 | + $this->processExtraData($pra, $user, $resource); |
|
105 | 105 | } |
106 | - $this->comparisonManager->compare( $pra ); |
|
106 | + $this->comparisonManager->compare($pra); |
|
107 | 107 | } |
108 | 108 | // The given result could be an array of rejected attributes or true |
109 | 109 | // True means that the rule is correctly enforced for the given user and resource |
110 | 110 | $result = $this->comparisonManager->getResult(); |
111 | - if ( true === $result ) { |
|
111 | + if (true === $result) { |
|
112 | 112 | break; |
113 | 113 | } |
114 | 114 | } |
115 | - if ( $cacheResult ) { |
|
116 | - $cacheItem->set( $result ); |
|
117 | - $this->cacheManager->save( $cacheItem ); |
|
115 | + if ($cacheResult) { |
|
116 | + $cacheItem->set($result); |
|
117 | + $this->cacheManager->save($cacheItem); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | return $result; |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | private function prepareGetterParams($getter_params, $user, $resource) { |
133 | 133 | if (empty($getter_params)) return []; |
134 | 134 | $values = []; |
135 | - foreach($getter_params as $getter_name=>$params) { |
|
136 | - foreach($params as $param) { |
|
137 | - if ( '@' !== $param[ 'param_name' ][ 0 ] ) { |
|
138 | - $values[$getter_name][] = $param[ 'param_value' ]; |
|
135 | + foreach ($getter_params as $getter_name=>$params) { |
|
136 | + foreach ($params as $param) { |
|
137 | + if ('@' !== $param['param_name'][0]) { |
|
138 | + $values[$getter_name][] = $param['param_value']; |
|
139 | 139 | } |
140 | 140 | else { |
141 | - $values[$getter_name][] = $this->attributeManager->retrieveAttribute( $this->attributeManager->getAttribute( $param[ 'param_value' ] ) , $user, $resource ); |
|
141 | + $values[$getter_name][] = $this->attributeManager->retrieveAttribute($this->attributeManager->getAttribute($param['param_value']), $user, $resource); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
@@ -150,26 +150,26 @@ discard block |
||
150 | 150 | * @param object $user |
151 | 151 | * @param object $resource |
152 | 152 | */ |
153 | - public function processExtraData( PolicyRuleAttribute $pra, $user, $resource ) { |
|
154 | - foreach ( $pra->getExtraData() as $key => $data ) { |
|
155 | - switch ( $key ) { |
|
153 | + public function processExtraData(PolicyRuleAttribute $pra, $user, $resource) { |
|
154 | + foreach ($pra->getExtraData() as $key => $data) { |
|
155 | + switch ($key) { |
|
156 | 156 | case 'with': |
157 | 157 | // This data has to be removed for it will be stored elsewhere |
158 | 158 | // in the policy rule attribute |
159 | - $pra->removeExtraData( 'with' ); |
|
159 | + $pra->removeExtraData('with'); |
|
160 | 160 | // The "with" extra data is an array of attributes, which are objects |
161 | 161 | // Once we process it as policy rule attributes, we set it as the main policy rule attribute value |
162 | 162 | $subPolicyRuleAttributes = []; |
163 | 163 | $extraData = []; |
164 | 164 | |
165 | - foreach ( $this->policyRuleManager->processRuleAttributes( $data, $user, $resource ) as $subPolicyRuleAttribute ) { |
|
165 | + foreach ($this->policyRuleManager->processRuleAttributes($data, $user, $resource) as $subPolicyRuleAttribute) { |
|
166 | 166 | $subPolicyRuleAttributes[] = $subPolicyRuleAttribute; |
167 | 167 | } |
168 | - $pra->setValue( $subPolicyRuleAttributes ); |
|
168 | + $pra->setValue($subPolicyRuleAttributes); |
|
169 | 169 | // This data can be used in complex comparisons |
170 | - $pra->addExtraData( 'attribute', $pra->getAttribute() ); |
|
171 | - $pra->addExtraData( 'user', $user ); |
|
172 | - $pra->addExtraData( 'resource', $resource ); |
|
170 | + $pra->addExtraData('attribute', $pra->getAttribute()); |
|
171 | + $pra->addExtraData('user', $user); |
|
172 | + $pra->addExtraData('resource', $resource); |
|
173 | 173 | break; |
174 | 174 | } |
175 | 175 | } |
@@ -130,14 +130,15 @@ |
||
130 | 130 | * @return array |
131 | 131 | */ |
132 | 132 | private function prepareGetterParams($getter_params, $user, $resource) { |
133 | - if (empty($getter_params)) return []; |
|
133 | + if (empty($getter_params)) { |
|
134 | + return []; |
|
135 | + } |
|
134 | 136 | $values = []; |
135 | 137 | foreach($getter_params as $getter_name=>$params) { |
136 | 138 | foreach($params as $param) { |
137 | 139 | if ( '@' !== $param[ 'param_name' ][ 0 ] ) { |
138 | 140 | $values[$getter_name][] = $param[ 'param_value' ]; |
139 | - } |
|
140 | - else { |
|
141 | + } else { |
|
141 | 142 | $values[$getter_name][] = $this->attributeManager->retrieveAttribute( $this->attributeManager->getAttribute( $param[ 'param_value' ] ) , $user, $resource ); |
142 | 143 | } |
143 | 144 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $user1Vehicle = $abac->enforce('vehicle-homologation', $users[0], $vehicles[0], [ |
35 | 35 | 'dynamic_attributes' => ['proprietaire' => 1] |
36 | 36 | ]); |
37 | - if($user1Vehicle === true) { |
|
37 | + if ($user1Vehicle === true) { |
|
38 | 38 | echo("GRANTED : The vehicle 1 is able to be approved for the user 1\n"); |
39 | 39 | } else { |
40 | 40 | echo("FAIL : The system didn't grant access\n"); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $user3Vehicle = $abac->enforce('vehicle-homologation', $users[2], $vehicles[1], [ |
43 | 43 | 'dynamic_attributes' => ['proprietaire' => 3] |
44 | 44 | ]); |
45 | - if(!$user3Vehicle !== true) { |
|
45 | + if (!$user3Vehicle !== true) { |
|
46 | 46 | echo("DENIED : The vehicle 2 is not approved for the user 3 because its last technical review is too old\n"); |
47 | 47 | } else { |
48 | 48 | echo("FAIL : The system didn't deny access\n"); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $user4Vehicle = $abac->enforce('vehicle-homologation', $users[3], $vehicles[3], [ |
51 | 51 | 'dynamic_attributes' => ['proprietaire' => 4] |
52 | 52 | ]); |
53 | - if($user4Vehicle !== true) { |
|
53 | + if ($user4Vehicle !== true) { |
|
54 | 54 | echo("DENIED : The vehicle 4 is not able to be approved for the user 4 because he has no driving license\n"); |
55 | 55 | } else { |
56 | 56 | echo("FAIL : The system didn't deny access\n"); |
@@ -58,19 +58,19 @@ discard block |
||
58 | 58 | $user5Vehicle = $abac->enforce('vehicle-homologation', $users[3], $vehicles[3], [ |
59 | 59 | 'dynamic_attributes' => ['proprietaire' => 1] |
60 | 60 | ]); |
61 | - if($user5Vehicle !== true) { |
|
61 | + if ($user5Vehicle !== true) { |
|
62 | 62 | echo("DENIED : The vehicle 4 is not able to be approved for the user 2 because he doesn't own the vehicle\n"); |
63 | 63 | } else { |
64 | 64 | echo("FAIL : The system didn't deny access\n"); |
65 | 65 | } |
66 | 66 | $userTravel1 = $abac->enforce('travel-to-usa', $users[0]); |
67 | - if($userTravel1 !== true) { |
|
67 | + if ($userTravel1 !== true) { |
|
68 | 68 | echo("DENIED: The user 1 is not allowed to travel to the USA because he doesn't have an US visa\n"); |
69 | 69 | } else { |
70 | 70 | echo('FAIL: The system didn\'t deny access'); |
71 | 71 | } |
72 | 72 | $userTravel2 = $abac->enforce('travel-to-usa', $users[1]); |
73 | - if($userTravel2 === true) { |
|
73 | + if ($userTravel2 === true) { |
|
74 | 74 | echo("GRANTED: The user 2 is allowed to travel to the USA\n"); |
75 | 75 | } else { |
76 | 76 | echo('FAIL: The system didn\'t deny access'); |
@@ -121,7 +121,7 @@ |
||
121 | 121 | * @return \PhpAbac\Model\PolicyRuleAttribute |
122 | 122 | */ |
123 | 123 | public function removeExtraData($key) { |
124 | - if(isset($this->extraData[$key])) { |
|
124 | + if (isset($this->extraData[$key])) { |
|
125 | 125 | unset($this->extraData[$key]); |
126 | 126 | } |
127 | 127 | return $this; |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | protected $value; |
15 | 15 | /** @var array **/ |
16 | 16 | protected $extraData; |
17 | - /** @var array Extended parameter */ |
|
18 | - protected $getter_params_a = []; |
|
17 | + /** @var array Extended parameter */ |
|
18 | + protected $getter_params_a = []; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @param \PhpAbac\Model\AbstractAttribute $attribute |
@@ -136,21 +136,21 @@ discard block |
||
136 | 136 | return $this->extraData; |
137 | 137 | } |
138 | 138 | |
139 | - /** |
|
140 | - * @param array $value |
|
141 | - * |
|
142 | - * @return static |
|
143 | - */ |
|
144 | - public function setGetterParams($value) { |
|
145 | - $this->getter_params_a = $value; |
|
139 | + /** |
|
140 | + * @param array $value |
|
141 | + * |
|
142 | + * @return static |
|
143 | + */ |
|
144 | + public function setGetterParams($value) { |
|
145 | + $this->getter_params_a = $value; |
|
146 | 146 | |
147 | - return $this; |
|
148 | - } |
|
147 | + return $this; |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * @return array |
|
152 | - */ |
|
153 | - public function getGetterParams() { |
|
154 | - return $this->getter_params_a; |
|
155 | - } |
|
150 | + /** |
|
151 | + * @return array |
|
152 | + */ |
|
153 | + public function getGetterParams() { |
|
154 | + return $this->getter_params_a; |
|
155 | + } |
|
156 | 156 | } |
@@ -6,7 +6,6 @@ |
||
6 | 6 | use PhpAbac\Manager\PolicyRuleManager; |
7 | 7 | use PhpAbac\Manager\ConfigurationManager; |
8 | 8 | use PhpAbac\Manager\CacheManager; |
9 | - |
|
10 | 9 | use Symfony\Component\Config\FileLocator; |
11 | 10 | |
12 | 11 | class Abac |
@@ -60,22 +60,22 @@ discard block |
||
60 | 60 | : $pra->getValue() |
61 | 61 | ; |
62 | 62 | // Checking that the configured comparison type is available |
63 | - if(!isset($this->comparisons[$pra->getComparisonType()])) { |
|
63 | + if (!isset($this->comparisons[$pra->getComparisonType()])) { |
|
64 | 64 | throw new \InvalidArgumentException('The requested comparison class does not exist'); |
65 | 65 | } |
66 | 66 | // The comparison class will perform the attribute check with the configured method |
67 | 67 | // For more complex comparisons, the comparison manager is injected |
68 | 68 | $comparison = new $this->comparisons[$pra->getComparisonType()]($this); |
69 | - if(!method_exists($comparison, $pra->getComparison())) { |
|
69 | + if (!method_exists($comparison, $pra->getComparison())) { |
|
70 | 70 | throw new \InvalidArgumentException('The requested comparison method does not exist'); |
71 | 71 | } |
72 | 72 | // Then the comparison is performed with needed |
73 | 73 | $result = $comparison->{$pra->getComparison()}($praValue, $attribute->getValue(), $pra->getExtraData()); |
74 | 74 | // If the checked attribute is not valid, the attribute slug is marked as rejected |
75 | 75 | // The rejected attributes will be returned instead of the expected true boolean |
76 | - if($result !== true) { |
|
76 | + if ($result !== true) { |
|
77 | 77 | // In case of sub comparing, the error reporting is disabled |
78 | - if(!in_array($attribute->getSlug(), $this->rejectedAttributes) && $subComparing === false) { |
|
78 | + if (!in_array($attribute->getSlug(), $this->rejectedAttributes) && $subComparing === false) { |
|
79 | 79 | $this->rejectedAttributes[] = $attribute->getSlug(); |
80 | 80 | } |
81 | 81 | return false; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @throws \InvalidArgumentException |
103 | 103 | */ |
104 | 104 | public function getDynamicAttribute($attributeSlug) { |
105 | - if(!isset($this->dynamicAttributes[$attributeSlug])) { |
|
105 | + if (!isset($this->dynamicAttributes[$attributeSlug])) { |
|
106 | 106 | throw new \InvalidArgumentException("The dynamic value for attribute $attributeSlug was not given"); |
107 | 107 | } |
108 | 108 | return $this->dynamicAttributes[$attributeSlug]; |
@@ -55,23 +55,23 @@ |
||
55 | 55 | * @return boolean |
56 | 56 | */ |
57 | 57 | public function contains($policyRuleAttributes, $attributes, $extraData = []) { |
58 | - foreach($extraData['attribute']->getValue() as $attribute) { |
|
58 | + foreach ($extraData['attribute']->getValue() as $attribute) { |
|
59 | 59 | $result = true; |
60 | 60 | // For each attribute, we check the whole rules set |
61 | - foreach($policyRuleAttributes as $pra) { |
|
61 | + foreach ($policyRuleAttributes as $pra) { |
|
62 | 62 | $attributeData = $pra->getAttribute(); |
63 | 63 | $attributeData->setValue( |
64 | 64 | $this->comparisonManager->getAttributeManager()->retrieveAttribute($attributeData, $extraData['user'], $attribute) |
65 | 65 | ); |
66 | 66 | // If one field is not matched, the whole attribute is rejected |
67 | - if(!$this->comparisonManager->compare($pra, true)) { |
|
67 | + if (!$this->comparisonManager->compare($pra, true)) { |
|
68 | 68 | //var_dump($attributeData->getName(), $attributeData->getValue(), $pra->getValue()); |
69 | 69 | $result = false; |
70 | 70 | break; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | // If the result is still true at the end of the attribute check, the rule is enforced |
74 | - if($result === true) { |
|
74 | + if ($result === true) { |
|
75 | 75 | return true; |
76 | 76 | } |
77 | 77 | } |