@@ -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 |
@@ -51,21 +51,21 @@ discard block |
||
51 | 51 | : $pra->getValue() |
52 | 52 | ; |
53 | 53 | // Checking that the configured comparison type is available |
54 | - if(!isset($this->comparisons[$pra->getComparisonType()])) { |
|
54 | + if (!isset($this->comparisons[$pra->getComparisonType()])) { |
|
55 | 55 | throw new \InvalidArgumentException('The requested comparison class does not exist'); |
56 | 56 | } |
57 | 57 | // The comparison class will perform the attribute check with the configured method |
58 | 58 | // For more complex comparisons, the comparison manager is injected |
59 | 59 | $comparison = new $this->comparisons[$pra->getComparisonType()]($this); |
60 | - if(!method_exists($comparison, $pra->getComparison())) { |
|
60 | + if (!method_exists($comparison, $pra->getComparison())) { |
|
61 | 61 | throw new \InvalidArgumentException('The requested comparison method does not exist'); |
62 | 62 | } |
63 | 63 | // Then the comparison is performed with needed |
64 | 64 | $result = $comparison->{$pra->getComparison()}($praValue, $attribute->getValue(), $pra->getExtraData()); |
65 | 65 | // If the checked attribute is not valid, the attribute slug is marked as rejected |
66 | 66 | // The rejected attributes will be returned instead of the expected true boolean |
67 | - if($result !== true) { |
|
68 | - if(!in_array($attribute->getSlug(), $this->rejectedAttributes)) { |
|
67 | + if ($result !== true) { |
|
68 | + if (!in_array($attribute->getSlug(), $this->rejectedAttributes)) { |
|
69 | 69 | $this->rejectedAttributes[] = $attribute->getSlug(); |
70 | 70 | } |
71 | 71 | return false; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @throws \InvalidArgumentException |
93 | 93 | */ |
94 | 94 | public function getDynamicAttribute($attributeSlug) { |
95 | - if(!isset($this->dynamicAttributes[$attributeSlug])) { |
|
95 | + if (!isset($this->dynamicAttributes[$attributeSlug])) { |
|
96 | 96 | throw new \InvalidArgumentException("The dynamic value for attribute $attributeSlug was not given"); |
97 | 97 | } |
98 | 98 | return $this->dynamicAttributes[$attributeSlug]; |
@@ -54,19 +54,19 @@ |
||
54 | 54 | * @return boolean |
55 | 55 | */ |
56 | 56 | public function contains($policyRuleAttributes, $attributes, $extraData = []) { |
57 | - foreach($extraData['attribute']->getValue() as $attribute) { |
|
57 | + foreach ($extraData['attribute']->getValue() as $attribute) { |
|
58 | 58 | $result = true; |
59 | - foreach($policyRuleAttributes as $pra) { |
|
59 | + foreach ($policyRuleAttributes as $pra) { |
|
60 | 60 | $attributeData = $pra->getAttribute(); |
61 | 61 | $attributeData->setValue( |
62 | 62 | $this->comparisonManager->getAttributeManager()->retrieveAttribute($attributeData, $extraData['user'], $attribute) |
63 | 63 | ); |
64 | - if(!$this->comparisonManager->compare($pra)) { |
|
64 | + if (!$this->comparisonManager->compare($pra)) { |
|
65 | 65 | $result = false; |
66 | 66 | break; |
67 | 67 | } |
68 | 68 | } |
69 | - if($result === true) { |
|
69 | + if ($result === true) { |
|
70 | 70 | return true; |
71 | 71 | } |
72 | 72 | } |