Test Failed
Push — develop ( bd8dda...9b21c2 )
by Craig
05:06
created
src/Helpers.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 */
18 18
 	public static function isAssocArray(array $array) :bool
19 19
 	{
20
-        if (array() === $array) return false;
21
-        return array_keys($array) !== range(0, count($array) - 1);
20
+		if (array() === $array) return false;
21
+		return array_keys($array) !== range(0, count($array) - 1);
22 22
 	}
23 23
 
24 24
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	}
180 180
 
181 181
 
182
-    /**
182
+	/**
183 183
 	 * Gets the module based on the classname
184 184
 	 * @param string $class
185 185
 	 * @return string
Please login to merge, or discard this patch.
Spacing   +27 added lines, -28 removed lines patch added patch discarded remove patch
@@ -34,8 +34,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Braces   +11 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@  discard block
 block discarded – undo
17 17
 	 */
18 18
 	public static function isAssocArray(array $array) :bool
19 19
 	{
20
-        if (array() === $array) return false;
20
+        if (array() === $array) {
21
+        	return false;
22
+        }
21 23
         return array_keys($array) !== range(0, count($array) - 1);
22 24
 	}
23 25
 
@@ -145,8 +147,7 @@  discard block
 block discarded – undo
145 147
 				{
146 148
 					$mod			 = Helpers::getModule($child['class']);
147 149
 					$assets[strtolower($mod)][strtolower($child['shortname'])]	 = $child;
148
-				}
149
-				else
150
+				} else
150 151
 				{
151 152
 					$assets[strtolower($child['shortname'])] = $child;
152 153
 				}
@@ -157,8 +158,7 @@  discard block
 block discarded – undo
157 158
 			{
158 159
 				$mod			 = Helpers::getModule($className);
159 160
 				$assets[strtolower($mod)][strtolower($asset['shortname'])]	 = $asset;
160
-			}
161
-			else
161
+			} else
162 162
 			{
163 163
 				$assets[strtolower($asset['shortname'])] = $asset;
164 164
 			}
@@ -261,14 +261,16 @@  discard block
 block discarded – undo
261 261
 		$i		 = 0;
262 262
 		while (!$class)
263 263
 		{
264
-			if (feof($fp))
265
-				break;
264
+			if (feof($fp)) {
265
+							break;
266
+			}
266 267
 
267 268
 			$buffer	 .= fread($fp, 512);
268 269
 			$tokens	 = token_get_all($buffer);
269 270
 
270
-			if (strpos($buffer, '{') === false)
271
-				continue;
271
+			if (strpos($buffer, '{') === false) {
272
+							continue;
273
+			}
272 274
 
273 275
 			for (; $i < count($tokens); $i++)
274 276
 			{
Please login to merge, or discard this patch.