@@ -121,6 +121,7 @@ |
||
121 | 121 | /** |
122 | 122 | * @throws \InvalidArgumentException |
123 | 123 | * |
124 | + * @param string $serviceName |
|
124 | 125 | * @return mixed |
125 | 126 | */ |
126 | 127 | public static function get($serviceName) |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | $attributeManager = self::get('attribute-manager'); |
49 | 49 | $cacheManager = self::get('cache-manager'); |
50 | 50 | |
51 | - if(($cacheResult = isset($options['cache_result']) && $options['cache_result'] === true) === true) { |
|
51 | + if (($cacheResult = isset($options['cache_result']) && $options['cache_result'] === true) === true) { |
|
52 | 52 | $cacheItem = $cacheManager->getItem( |
53 | 53 | "$ruleName-$userId-$objectId", |
54 | 54 | (isset($options['cache_driver'])) ? $options['cache_driver'] : null, |
55 | 55 | (isset($options['cache_ttl'])) ? $options['cache_ttl'] : null |
56 | 56 | ); |
57 | - if(($cacheValue = $cacheItem->get()) !== null) { |
|
57 | + if (($cacheValue = $cacheItem->get()) !== null) { |
|
58 | 58 | return $cacheValue; |
59 | 59 | } |
60 | 60 | } |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | $rejectedAttributes[] = $attribute->getSlug(); |
78 | 78 | } |
79 | 79 | } |
80 | - $result = (count($rejectedAttributes) === 0) ? : $rejectedAttributes; |
|
81 | - if($cacheResult) { |
|
80 | + $result = (count($rejectedAttributes) === 0) ?: $rejectedAttributes; |
|
81 | + if ($cacheResult) { |
|
82 | 82 | $cacheItem->set($result); |
83 | 83 | $cacheManager->save($cacheItem); |
84 | 84 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @param Attribute &$attribute |
36 | - * @param mixed $criteria |
|
36 | + * @param integer $criteria |
|
37 | 37 | */ |
38 | 38 | public function retrieveAttribute(Attribute $attribute, $criteria) |
39 | 39 | { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $slug = $this->slugify($attribute->getName()); |
55 | 55 | |
56 | 56 | $this->insert( |
57 | - 'INSERT INTO abac_attributes_data (created_at, updated_at, name, slug) ' . |
|
57 | + 'INSERT INTO abac_attributes_data (created_at, updated_at, name, slug) '. |
|
58 | 58 | 'VALUES(:created_at, :updated_at, :name, :slug);', [ |
59 | 59 | 'name' => $attribute->getName(), |
60 | 60 | 'slug' => $slug, |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $id = $this->connection->lastInsertId('abac_attributes_data'); |
66 | 66 | |
67 | 67 | $this->insert( |
68 | - 'INSERT INTO abac_attributes (id, table_name, column_name, criteria_column) ' . |
|
68 | + 'INSERT INTO abac_attributes (id, table_name, column_name, criteria_column) '. |
|
69 | 69 | 'VALUES(:id, :table_name, :column_name, :criteria_column);', [ |
70 | 70 | 'id' => $id, |
71 | 71 | 'table_name' => $attribute->getTable(), |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $slug = $this->slugify($attribute->getName()); |
92 | 92 | |
93 | 93 | $this->insert( |
94 | - 'INSERT INTO abac_attributes_data (created_at, updated_at, name, slug) ' . |
|
94 | + 'INSERT INTO abac_attributes_data (created_at, updated_at, name, slug) '. |
|
95 | 95 | 'VALUES(:created_at, :updated_at, :name, :slug);', [ |
96 | 96 | 'name' => $attribute->getName(), |
97 | 97 | 'slug' => $slug, |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $id = $this->connection->lastInsertId('abac_attributes_data'); |
103 | 103 | |
104 | 104 | $this->insert( |
105 | - 'INSERT INTO abac_environment_attributes (id, variable_name) ' . |
|
105 | + 'INSERT INTO abac_environment_attributes (id, variable_name) '. |
|
106 | 106 | 'VALUES(:id, :variable_name);', [ |
107 | 107 | 'id' => $id, |
108 | 108 | 'variable_name' => $attribute->getVariableName(), |
@@ -10,7 +10,6 @@ |
||
10 | 10 | protected $connection; |
11 | 11 | |
12 | 12 | /** |
13 | - * @param \PDO $connection |
|
14 | 13 | */ |
15 | 14 | public function __construct() |
16 | 15 | { |
@@ -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]; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | } |
23 | 23 | |
24 | 24 | $user2Nationality = $abac->enforce('nationality-access', 2); |
25 | - if ($user2Nationality !== true) { |
|
25 | + if ($user2Nationality !== true) { |
|
26 | 26 | echo("DENIED : The user 2 is not able to be nationalized because he hasn't done his JAPD\n"); |
27 | 27 | } else { |
28 | 28 | echo("FAIL : The system didn't deny access\n"); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $user1Vehicle = $abac->enforce('vehicle-homologation', 1, 1, [ |
32 | 32 | 'dynamic_attributes' => ['proprietaire' => 1] |
33 | 33 | ]); |
34 | - if($user1Vehicle === true) { |
|
34 | + if ($user1Vehicle === true) { |
|
35 | 35 | echo("GRANTED : The vehicle 1 is able to be approved for the user 1\n"); |
36 | 36 | } else { |
37 | 37 | echo("FAIL : The system didn't grant access\n"); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $user3Vehicle = $abac->enforce('vehicle-homologation', 3, 2, [ |
40 | 40 | 'dynamic_attributes' => ['proprietaire' => 3] |
41 | 41 | ]); |
42 | - if(!$user3Vehicle !== true) { |
|
42 | + if (!$user3Vehicle !== true) { |
|
43 | 43 | echo("DENIED : The vehicle 2 is not approved for the user 3 because its last technical review is too old\n"); |
44 | 44 | } else { |
45 | 45 | echo("FAIL : The system didn't deny access\n"); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $user4Vehicle = $abac->enforce('vehicle-homologation', 4, 4, [ |
48 | 48 | 'dynamic_attributes' => ['proprietaire' => 4] |
49 | 49 | ]); |
50 | - if($user4Vehicle !== true) { |
|
50 | + if ($user4Vehicle !== true) { |
|
51 | 51 | echo("DENIED : The vehicle 4 is not able to be approved for the user 4 because he has no driving license\n"); |
52 | 52 | } else { |
53 | 53 | echo("FAIL : The system didn't deny access\n"); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $user5Vehicle = $abac->enforce('vehicle-homologation', 4, 2, [ |
56 | 56 | 'dynamic_attributes' => ['proprietaire' => 1] |
57 | 57 | ]); |
58 | - if($user5Vehicle !== true) { |
|
58 | + if ($user5Vehicle !== true) { |
|
59 | 59 | echo("DENIED : The vehicle 4 is not able to be approved for the user 2 because he doesn't own the vehicle\n"); |
60 | 60 | } else { |
61 | 61 | echo("FAIL : The system didn't deny access\n"); |