@@ -34,8 +34,7 @@ discard block |
||
34 | 34 | $pattern = "/(.)([A-Z])/"; |
35 | 35 | $replacement = "\\1 \\2"; |
36 | 36 | $return = ($ucfirst) ? |
37 | - ucfirst(preg_replace($pattern, $replacement, $string)) : |
|
38 | - strtolower(preg_replace($pattern, $replacement, $string)); |
|
37 | + ucfirst(preg_replace($pattern, $replacement, $string)) : strtolower(preg_replace($pattern, $replacement, $string)); |
|
39 | 38 | |
40 | 39 | return ($glue !== null) ? str_replace(' ', $glue, $return) : $return; |
41 | 40 | } |
@@ -51,7 +50,7 @@ discard block |
||
51 | 50 | public static function parseAssetType(string $queryString, bool $key = false) |
52 | 51 | { |
53 | 52 | $assetParts = explode(".", strtolower($queryString)); |
54 | - if(count($assetParts) > 2){ |
|
53 | + if (count($assetParts) > 2) { |
|
55 | 54 | throw new DatastoreException("Assets are only 2 tiers deep"); |
56 | 55 | } |
57 | 56 | $asset = array_pop($assetParts); |
@@ -59,7 +58,7 @@ discard block |
||
59 | 58 | |
60 | 59 | $list = !empty($assetParts) && isset($list[$assetParts[0]]) ? $list[$assetParts[0]] : array_shift($list); |
61 | 60 | |
62 | - if(!isset($list[$asset])){ |
|
61 | + if (!isset($list[$asset])) { |
|
63 | 62 | throw new DatastoreException("Asset not found"); |
64 | 63 | } |
65 | 64 | return $key ? $list[$asset]['class'] : $list[$asset]; |
@@ -90,22 +89,22 @@ discard block |
||
90 | 89 | ); |
91 | 90 | } |
92 | 91 | |
93 | - public static function getStatusEquals($className){ |
|
92 | + public static function getStatusEquals($className) { |
|
94 | 93 | $statusEquals = self::assetInfo($className, 'status_equals'); |
95 | - if(!$statusEquals){ |
|
94 | + if (!$statusEquals) { |
|
96 | 95 | return null; |
97 | 96 | } |
98 | - $props = self::getAssetProps($className,$statusEquals); |
|
99 | - return isset($props['published'])?$props['published'] : null; |
|
97 | + $props = self::getAssetProps($className, $statusEquals); |
|
98 | + return isset($props['published']) ? $props['published'] : null; |
|
100 | 99 | } |
101 | 100 | |
102 | 101 | |
103 | - public static function getAssetProps($className, $property = null){ |
|
102 | + public static function getAssetProps($className, $property = null) { |
|
104 | 103 | $properties = self::assetInfo($className, 'properties'); |
105 | - if(!$properties){ |
|
104 | + if (!$properties) { |
|
106 | 105 | throw new DatastoreException("No Properties found for asset"); |
107 | 106 | } |
108 | - if($property){ |
|
107 | + if ($property) { |
|
109 | 108 | return isset($properties[$property]) ? $properties[$property] : null; |
110 | 109 | } |
111 | 110 | return $properties; |
@@ -123,7 +122,7 @@ discard block |
||
123 | 122 | { |
124 | 123 | $assets = array(); |
125 | 124 | $datastoreAssets = config("datastore.assets"); |
126 | - foreach($datastoreAssets as $className){ |
|
125 | + foreach ($datastoreAssets as $className) { |
|
127 | 126 | |
128 | 127 | $asset = self::getAssetItem($className); |
129 | 128 | |
@@ -131,20 +130,20 @@ discard block |
||
131 | 130 | throw new DatastoreException('Only assets of type assets should be used ' . $className); |
132 | 131 | } |
133 | 132 | |
134 | - if(!$includeChildren && $asset['is_child']){ |
|
133 | + if (!$includeChildren && $asset['is_child']) { |
|
135 | 134 | continue; |
136 | 135 | } |
137 | 136 | |
138 | - if($asset['children'] && $includeChildren && !in_array($asset['children'], $datastoreAssets)){ |
|
139 | - $child = self::getAssetItem($asset['children']); |
|
137 | + if ($asset['children'] && $includeChildren && !in_array($asset['children'], $datastoreAssets)) { |
|
138 | + $child = self::getAssetItem($asset['children']); |
|
140 | 139 | if (self::assetNamespace($child['class']) !== 'asset') { |
141 | 140 | throw new DatastoreException('Only assets of type assets should be used ' . $child['class']); |
142 | 141 | } |
143 | 142 | |
144 | 143 | if ($grouped) |
145 | 144 | { |
146 | - $mod = Helpers::getModule($child['class']); |
|
147 | - $assets[strtolower($mod)][strtolower($child['shortname'])] = $child; |
|
145 | + $mod = Helpers::getModule($child['class']); |
|
146 | + $assets[strtolower($mod)][strtolower($child['shortname'])] = $child; |
|
148 | 147 | } |
149 | 148 | else |
150 | 149 | { |
@@ -155,8 +154,8 @@ discard block |
||
155 | 154 | |
156 | 155 | if ($grouped) |
157 | 156 | { |
158 | - $mod = Helpers::getModule($className); |
|
159 | - $assets[strtolower($mod)][strtolower($asset['shortname'])] = $asset; |
|
157 | + $mod = Helpers::getModule($className); |
|
158 | + $assets[strtolower($mod)][strtolower($asset['shortname'])] = $asset; |
|
160 | 159 | } |
161 | 160 | else |
162 | 161 | { |
@@ -167,9 +166,9 @@ discard block |
||
167 | 166 | } |
168 | 167 | |
169 | 168 | ksort($assets); |
170 | - if($grouped){ |
|
171 | - foreach($assets as &$group){ |
|
172 | - uasort($group, function ($a , $b) { |
|
169 | + if ($grouped) { |
|
170 | + foreach ($assets as &$group) { |
|
171 | + uasort($group, function($a, $b) { |
|
173 | 172 | return strcmp($a['name'], $b['name']); |
174 | 173 | }); |
175 | 174 | } |
@@ -189,7 +188,7 @@ discard block |
||
189 | 188 | $parts = explode('\\', $class); |
190 | 189 | array_pop($parts); |
191 | 190 | $ns = ''; |
192 | - if(end($parts) !== 'Ams'){ |
|
191 | + if (end($parts) !== 'Ams') { |
|
193 | 192 | $ns = ucfirst(array_pop($parts)); |
194 | 193 | } |
195 | 194 | |
@@ -217,7 +216,7 @@ discard block |
||
217 | 216 | { |
218 | 217 | $mod = self::getModule($className); |
219 | 218 | $sn = Self::assetInfo($className, 'shortname'); |
220 | - return !empty($mod) ? strtolower($mod .'.' . $sn) : strtolower($sn); |
|
219 | + return !empty($mod) ? strtolower($mod . '.' . $sn) : strtolower($sn); |
|
221 | 220 | } |
222 | 221 | |
223 | 222 | /** |
@@ -257,15 +256,15 @@ discard block |
||
257 | 256 | } |
258 | 257 | $fp = fopen(FCPATH . $file, 'r'); |
259 | 258 | |
260 | - $class = $buffer = ''; |
|
261 | - $i = 0; |
|
259 | + $class = $buffer = ''; |
|
260 | + $i = 0; |
|
262 | 261 | while (!$class) |
263 | 262 | { |
264 | 263 | if (feof($fp)) |
265 | 264 | break; |
266 | 265 | |
267 | - $buffer .= fread($fp, 512); |
|
268 | - $tokens = token_get_all($buffer); |
|
266 | + $buffer .= fread($fp, 512); |
|
267 | + $tokens = token_get_all($buffer); |
|
269 | 268 | |
270 | 269 | if (strpos($buffer, '{') === false) |
271 | 270 | continue; |