@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | protected function getPolicyMap() { |
39 | 39 | // Try to to get the cached map if there is one |
40 | - if(Cache::has(self::CACHE_KEY) && !App::isLocal()) { |
|
40 | + if (Cache::has(self::CACHE_KEY) && !App::isLocal()) { |
|
41 | 41 | return Cache::get(self::CACHE_KEY); |
42 | 42 | } |
43 | 43 | |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | // Initialize the policy map |
48 | 48 | $map = []; |
49 | 49 | |
50 | - foreach($policies as $policy) { |
|
50 | + foreach ($policies as $policy) { |
|
51 | 51 | $data = $this->getPolicyData($policy); |
52 | 52 | |
53 | 53 | // Check if the model is not being used as a duplicate |
54 | - if(isset($map[$data['model']])) |
|
54 | + if (isset($map[$data['model']])) |
|
55 | 55 | throw new Exception('The model "' . $data['model'] . '" is being used for more than one policy."'); |
56 | 56 | |
57 | 57 | // Assign the policy its spot in the policy map |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | // Cache the map and return it |
62 | - if(!App::isLocal()) |
|
62 | + if (!App::isLocal()) |
|
63 | 63 | Cache::put(self::CACHE_KEY, $map, self::CACHE_TIME); |
64 | 64 | |
65 | 65 | return $map; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $path = app_path('Policies'); |
75 | 75 | |
76 | 76 | // Return an empty array if there are no policies at all |
77 | - if(!file_exists($path)) |
|
77 | + if (!file_exists($path)) |
|
78 | 78 | return []; |
79 | 79 | |
80 | 80 | // Scan for policies |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | // Remove hidden items |
84 | 84 | foreach ($policies as $key => $policy) |
85 | - if(starts_with($policy, '.')) unset($policies[$key]); |
|
85 | + if (starts_with($policy, '.')) unset($policies[$key]); |
|
86 | 86 | |
87 | 87 | return $policies; |
88 | 88 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | // Attempt to get the model |
108 | 108 | $model = $reflection->getConstant('MODEL'); |
109 | 109 | |
110 | - if(!$model) throw new Exception('The policy "' . $policyClassName . '" is not bound to any model.'); |
|
110 | + if (!$model) throw new Exception('The policy "' . $policyClassName . '" is not bound to any model.'); |
|
111 | 111 | |
112 | 112 | // Return the policy data |
113 | 113 | return [ |
@@ -51,16 +51,18 @@ discard block |
||
51 | 51 | $data = $this->getPolicyData($policy); |
52 | 52 | |
53 | 53 | // Check if the model is not being used as a duplicate |
54 | - if(isset($map[$data['model']])) |
|
55 | - throw new Exception('The model "' . $data['model'] . '" is being used for more than one policy."'); |
|
54 | + if(isset($map[$data['model']])) { |
|
55 | + throw new Exception('The model "' . $data['model'] . '" is being used for more than one policy."'); |
|
56 | + } |
|
56 | 57 | |
57 | 58 | // Assign the policy its spot in the policy map |
58 | 59 | $map[$data['model']] = $data['policy']; |
59 | 60 | } |
60 | 61 | |
61 | 62 | // Cache the map and return it |
62 | - if(!App::isLocal()) |
|
63 | - Cache::put(self::CACHE_KEY, $map, self::CACHE_TIME); |
|
63 | + if(!App::isLocal()) { |
|
64 | + Cache::put(self::CACHE_KEY, $map, self::CACHE_TIME); |
|
65 | + } |
|
64 | 66 | |
65 | 67 | return $map; |
66 | 68 | } |
@@ -74,15 +76,17 @@ discard block |
||
74 | 76 | $path = app_path('Policies'); |
75 | 77 | |
76 | 78 | // Return an empty array if there are no policies at all |
77 | - if(!file_exists($path)) |
|
78 | - return []; |
|
79 | + if(!file_exists($path)) { |
|
80 | + return []; |
|
81 | + } |
|
79 | 82 | |
80 | 83 | // Scan for policies |
81 | 84 | $policies = scandir($path); |
82 | 85 | |
83 | 86 | // Remove hidden items |
84 | - foreach ($policies as $key => $policy) |
|
85 | - if(starts_with($policy, '.')) unset($policies[$key]); |
|
87 | + foreach ($policies as $key => $policy) { |
|
88 | + if(starts_with($policy, '.')) unset($policies[$key]); |
|
89 | + } |
|
86 | 90 | |
87 | 91 | return $policies; |
88 | 92 | } |
@@ -107,7 +111,9 @@ discard block |
||
107 | 111 | // Attempt to get the model |
108 | 112 | $model = $reflection->getConstant('MODEL'); |
109 | 113 | |
110 | - if(!$model) throw new Exception('The policy "' . $policyClassName . '" is not bound to any model.'); |
|
114 | + if(!$model) { |
|
115 | + throw new Exception('The policy "' . $policyClassName . '" is not bound to any model.'); |
|
116 | + } |
|
111 | 117 | |
112 | 118 | // Return the policy data |
113 | 119 | return [ |