Completed
Push — master ( 28be9d...cc0dae )
by Raphael
02:46
created
src/Scaffolder/Compilers/Blade/EditViewCompiler.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 		if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT)))
31 31
 		{
32 32
 			return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
33
-		}
34
-		else
33
+		} else
35 34
 		{
36 35
 			$this->stub = $stub;
37 36
 
@@ -67,8 +66,7 @@  discard block
 block discarded – undo
67 66
 		if ($fileToCompile->cached)
68 67
 		{
69 68
 			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
70
-		}
71
-		else
69
+		} else
72 70
 		{
73 71
 			File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
74 72
 			File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path);
@@ -95,8 +93,7 @@  discard block
 block discarded – undo
95 93
 			{
96 94
 				$fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name);
97 95
 				$firstIteration = false;
98
-			}
99
-			else
96
+			} else
100 97
 			{
101 98
 				$fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name);
102 99
 			}
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/Blade/IndexViewCompiler.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@  discard block
 block discarded – undo
26 26
         if (File::exists(base_path('scaffolder-config/cache/view_index_' . $hash . self::CACHE_EXT)))
27 27
         {
28 28
             return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash));
29
-        }
30
-        else
29
+        } else
31 30
         {
32 31
             $this->stub = $stub;
33 32
 
@@ -58,8 +57,7 @@  discard block
 block discarded – undo
58 57
         if ($fileToCompile->cached)
59 58
         {
60 59
             File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path);
61
-        }
62
-        else
60
+        } else
63 61
         {
64 62
             File::put(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $compiled);
65 63
             File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path);
@@ -89,8 +87,7 @@  discard block
 block discarded – undo
89 87
                 {
90 88
                     $fields .= sprintf("{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name);
91 89
                     $firstIteration = false;
92
-                }
93
-                else
90
+                } else
94 91
                 {
95 92
                     $fields .= sprintf("\t\t\t\t{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name);
96 93
                 }
@@ -124,8 +121,7 @@  discard block
 block discarded – undo
124 121
                     $fields .= sprintf("<th>%s</th>" . PHP_EOL, ucfirst($field->name));
125 122
                     $firstIteration = false;
126 123
 
127
-                }
128
-                else
124
+                } else
129 125
                 {
130 126
                     $fields .= sprintf("\t\t\t<th>%s</th>" . PHP_EOL, ucfirst($field->name));
131 127
                 }
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/AngularJs/ListTemplateCompiler.php 1 patch
Braces   +13 added lines, -14 removed lines patch added patch discarded remove patch
@@ -122,10 +122,11 @@  discard block
 block discarded – undo
122 122
 		$inputValidations = '' ; 
123 123
 
124 124
 		foreach ($validationsConverted as $attribute => $value) {
125
-			if($value)
126
-				$inputValidations .=  ' '.$attribute.'="'. $value.'"' ;
127
-			else
128
-				$inputValidations .=  ' '.$attribute  ; 
125
+			if($value) {
126
+							$inputValidations .=  ' '.$attribute.'="'. $value.'"' ;
127
+			} else {
128
+							$inputValidations .=  ' '.$attribute  ;
129
+			}
129 130
 		}
130 131
 
131 132
 		$fieldStub = str_replace('{{field_validation}}', $inputValidations, $fieldStub);
@@ -174,21 +175,19 @@  discard block
 block discarded – undo
174 175
 		
175 176
 		if($field->index == 'primary'){
176 177
 			$uiType = 'primary' ;
177
-		}
178
-		elseif(isset($field->foreignKey) && $field->foreignKey){
179
-			if(isset($field->foreignKey->eager) && $field->foreignKey->eager)
180
-				$uiType = 'foreign_eager' ;
181
-			else 
182
-				$uiType = $field->type->ui ;
183
-		}
184
-		else {
178
+		} elseif(isset($field->foreignKey) && $field->foreignKey){
179
+			if(isset($field->foreignKey->eager) && $field->foreignKey->eager) {
180
+							$uiType = 'foreign_eager' ;
181
+			} else {
182
+							$uiType = $field->type->ui ;
183
+			}
184
+		} else {
185 185
 			$uiType = $field->type->ui ;
186 186
 		}
187 187
 
188 188
 		if(array_key_exists($uiType, $this->inputStub)){
189 189
 			return $this->inputStub[$uiType];
190
-		}
191
-		else {
190
+		} else {
192 191
 			$this->inputStub[$uiType] = File::get($this->stubsDirectory . 'List/'. CamelCase::convertToCamelCase($uiType). '.html');
193 192
 
194 193
 			return $this->inputStub[$uiType];
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/AngularJs/IndexApiCompiler.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,8 +41,7 @@
 block discarded – undo
41 41
 		if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix  . self::CACHE_EXT)))
42 42
 		{
43 43
 			return $this->store(new FileToCompile(true, $this->cachePrefix));
44
-		}
45
-		else
44
+		} else
46 45
 		{
47 46
 
48 47
 			return $this->replaceAndStore();
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/AngularJs/RegisterTemplateCompiler.php 1 patch
Braces   +13 added lines, -14 removed lines patch added patch discarded remove patch
@@ -153,10 +153,11 @@  discard block
 block discarded – undo
153 153
 		$inputValidations = '' ; 
154 154
 
155 155
 		foreach ($validationsConverted as $attribute => $value) {
156
-			if($value)
157
-				$inputValidations .=  ' '.$attribute.'="'. $value.'"' ;
158
-			else
159
-				$inputValidations .=  ' '.$attribute  ; 
156
+			if($value) {
157
+							$inputValidations .=  ' '.$attribute.'="'. $value.'"' ;
158
+			} else {
159
+							$inputValidations .=  ' '.$attribute  ;
160
+			}
160 161
 		}
161 162
 
162 163
 		$fieldStub = str_replace('{{field_validation}}', $inputValidations, $fieldStub);
@@ -177,21 +178,19 @@  discard block
 block discarded – undo
177 178
 		
178 179
 		if($field->index == 'primary'){
179 180
 			$uiType = 'primary' ;
180
-		}
181
-		elseif(isset($field->foreignKey) && $field->foreignKey){
182
-			if(isset($field->foreignKey->eager) && $field->foreignKey->eager)
183
-				$uiType = 'foreign_eager' ;
184
-			else 
185
-				$uiType = $field->type->ui ;
186
-		}
187
-		else {
181
+		} elseif(isset($field->foreignKey) && $field->foreignKey){
182
+			if(isset($field->foreignKey->eager) && $field->foreignKey->eager) {
183
+							$uiType = 'foreign_eager' ;
184
+			} else {
185
+							$uiType = $field->type->ui ;
186
+			}
187
+		} else {
188 188
 			$uiType = $field->type->ui ;
189 189
 		}
190 190
 
191 191
 		if(array_key_exists($uiType, $this->inputStub)){
192 192
 			return $this->inputStub[$uiType];
193
-		}
194
-		else {
193
+		} else {
195 194
 			$this->inputStub[$uiType] = File::get($this->stubsDirectory . 'Register/'. CamelCase::convertToCamelCase($uiType). '.html');
196 195
 
197 196
 			return $this->inputStub[$uiType];
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/AbstractCompiler.php 1 patch
Braces   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -43,8 +43,7 @@  discard block
 block discarded – undo
43 43
 		if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix  . $this->modelData->modelHash . self::CACHE_EXT)))
44 44
 		{
45 45
 			return $this->store(new FileToCompile(true, $this->modelData->modelHash));
46
-		}
47
-		else
46
+		} else
48 47
 		{
49 48
 
50 49
 			return $this->replacePrimaryKey()
@@ -88,8 +87,7 @@  discard block
 block discarded – undo
88 87
 		if ($fileToCompile->cached)
89 88
 		{
90 89
 			File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path);
91
-		}
92
-		else
90
+		} else
93 91
 		{
94 92
 			File::put(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $this->stub);
95 93
 			File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path);
@@ -197,8 +195,9 @@  discard block
 block discarded – undo
197 195
 		$replaceStub = str_replace('{{foreign_model}}', ucwords($field->foreignKey->table), $replaceStub);
198 196
 		$replaceStub = str_replace('{{field}}', $field->name, $replaceStub);
199 197
 
200
-		if(isset($this->scaffolderConfig->generator->namespaces))
201
-			$replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub);
198
+		if(isset($this->scaffolderConfig->generator->namespaces)) {
199
+					$replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub);
200
+		}
202 201
 
203 202
 		return $replaceStub;
204 203
 		
@@ -215,7 +214,9 @@  discard block
 block discarded – undo
215 214
 	protected function replaceFieldStrings($field,  $originalStubPart){
216 215
 		$replaceStub = str_replace('{{field}}', $field->name, $originalStubPart);
217 216
 		
218
-		if($this->eagerTable) $this->eagerTable.'.' ;
217
+		if($this->eagerTable) {
218
+		    $this->eagerTable.'.' ;
219
+		}
219 220
 
220 221
 		$replaceStub = str_replace('{{eager_table}}', $this->eagerTable, $replaceStub);
221 222
 
@@ -247,8 +248,7 @@  discard block
 block discarded – undo
247 248
 		
248 249
 		if(array_key_exists($tableName, $this->modelDataArray)){
249 250
 			return $this->modelDataArray[$tableName];
250
-		}
251
-		else {
251
+		} else {
252 252
 
253 253
 			$modelFilename = base_path('scaffolder-config/models/') . $tableName . '.json' ;
254 254
 
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/Core/ModelCompiler.php 1 patch
Braces   +51 added lines, -56 removed lines patch added patch discarded remove patch
@@ -16,8 +16,9 @@  discard block
 block discarded – undo
16 16
 
17 17
 	public function __construct($scaffolderConfig, $modelData = null, $stubName = null)
18 18
 	{
19
-		if ($stubName)
20
-			$this->stubFilename = $stubName;
19
+		if ($stubName) {
20
+					$this->stubFilename = $stubName;
21
+		}
21 22
 		$this->stubsDirectory = __DIR__ . '/../../../../stubs/Api/';
22 23
 		parent::__construct($scaffolderConfig, $modelData);
23 24
 	}
@@ -91,19 +92,21 @@  discard block
 block discarded – undo
91 92
 
92 93
 		foreach ($this->modelData->fields as $field)
93 94
 		{
94
-			if($field->index == "primary")
95
-				continue ;
96
-			if($this->modelData->timeStamps && $field->name == "created_at")
97
-				continue ;
98
-			if($this->modelData->timeStamps && $field->name == "updated_at")
99
-				continue ;
95
+			if($field->index == "primary") {
96
+							continue ;
97
+			}
98
+			if($this->modelData->timeStamps && $field->name == "created_at") {
99
+							continue ;
100
+			}
101
+			if($this->modelData->timeStamps && $field->name == "updated_at") {
102
+							continue ;
103
+			}
100 104
 
101 105
 			if ($firstIteration)
102 106
 			{
103 107
 				$fields .= sprintf("'%s'," . PHP_EOL, $field->name);
104 108
 				$firstIteration = false;
105
-			}
106
-			else
109
+			} else
107 110
 			{
108 111
 				$fields .= sprintf("\t\t'%s'," . PHP_EOL, $field->name);
109 112
 			}
@@ -127,8 +130,9 @@  discard block
 block discarded – undo
127 130
 				
128 131
 				foreach ($field->options as $key => $option) {
129 132
 					$items .= "'" . $option . "'";
130
-					if ($key < (count($field->options) - 1))
131
-						$items .= ", ";
133
+					if ($key < (count($field->options) - 1)) {
134
+											$items .= ", ";
135
+					}
132 136
 
133 137
 				}
134 138
 
@@ -160,19 +164,21 @@  discard block
 block discarded – undo
160 164
 
161 165
 		foreach ($this->modelData->fields as $field)
162 166
 		{
163
-			if($field->index == "primary")
164
-				continue ;
165
-			if($this->modelData->timeStamps && $field->name == "created_at")
166
-				continue ;
167
-			if($this->modelData->timeStamps && $field->name == "updated_at")
168
-				continue ;
167
+			if($field->index == "primary") {
168
+							continue ;
169
+			}
170
+			if($this->modelData->timeStamps && $field->name == "created_at") {
171
+							continue ;
172
+			}
173
+			if($this->modelData->timeStamps && $field->name == "updated_at") {
174
+							continue ;
175
+			}
169 176
 
170 177
 			if ($firstIteration)
171 178
 			{
172 179
 				$fields .= sprintf("'%s' => '%s'," . PHP_EOL, $field->name, $field->validations);
173 180
 				$firstIteration = false;
174
-			}
175
-			else
181
+			} else
176 182
 			{
177 183
 				$fields .= sprintf("\t\t\t'%s' => '%s'," . PHP_EOL, $field->name, $field->validations);
178 184
 			}
@@ -245,8 +251,7 @@  discard block
 block discarded – undo
245 251
 					$belongsToStub = str_replace('{{foreign_model}}', CamelCase::convertToCamelCase($field->foreignKey->table), $belongsToOriginalStub);
246 252
 					$belongsToStub = str_replace('{{field}}', $field->name, $belongsToStub);
247 253
 					$belongsToStub = str_replace('{{foreign_field}}', $field->foreignKey->field, $belongsToStub);
248
-				}
249
-				elseif ($field->foreignKey->relationship == "belongsToMany") {
254
+				} elseif ($field->foreignKey->relationship == "belongsToMany") {
250 255
 					$belongsToOriginalStub = File::get($this->stubsDirectory . '/Model/ModelBelongsToMany.php');
251 256
 					$functionName = CamelCase::pluralize($field->foreignKey->table);
252 257
 					$belongsToStub = str_replace('{{foreign_model}}', CamelCase::convertToCamelCase($field->foreignKey->table), $belongsToOriginalStub);
@@ -289,10 +294,11 @@  discard block
 block discarded – undo
289 294
 			{
290 295
 				$reverseRelationshipStub = "";
291 296
 				$functionName = '';
292
-				if ($relationship->type == "hasOne")
293
-					$functionName = strtolower($relationship->modelName);
294
-				else 
295
-					$functionName = CamelCase::pluralize(strtolower($relationship->modelName));
297
+				if ($relationship->type == "hasOne") {
298
+									$functionName = strtolower($relationship->modelName);
299
+				} else {
300
+									$functionName = CamelCase::pluralize(strtolower($relationship->modelName));
301
+				}
296 302
 				
297 303
 				if ($relationship->type == "belongsToMany") {
298 304
 					$reverseRelationshipOriginalStub = File::get($this->stubsDirectory . '/Model/ModelBelongsToMany.php');
@@ -301,8 +307,7 @@  discard block
 block discarded – undo
301 307
 					$reverseRelationshipStub = str_replace('{{table_name}}', $relationship->tableName, $reverseRelationshipStub);
302 308
 					$reverseRelationshipStub = str_replace('{{related_field}}', $relationship->relatedField, $reverseRelationshipStub);
303 309
 					$reverseRelationshipStub = str_replace('{{foreign_table}}', CamelCase::pluralize(strtolower($relationship->relatedTable)), $reverseRelationshipStub);
304
-				}
305
-				else {
310
+				} else {
306 311
 					$reverseRelationshipOriginalStub = File::get($this->stubsDirectory . '/Model/ModelReverseRelationship.php');
307 312
 					$reverseRelationshipStub = str_replace('{{foreign_model}}', $relationship->modelName, $reverseRelationshipOriginalStub);
308 313
 					$reverseRelationshipStub = str_replace('{{field}}', $relationship->foreignKey, $reverseRelationshipStub);
@@ -532,27 +537,21 @@  discard block
 block discarded – undo
532 537
 		
533 538
 		if($field->index == 'primary'){
534 539
 			$dbType = 'primary' ;
535
-		}
536
-		elseif($field->foreignKey){
540
+		} elseif($field->foreignKey){
537 541
 			$dbType = 'primary' ;
538
-		}
539
-		elseif($field->type->db == 'enum'){
542
+		} elseif($field->type->db == 'enum'){
540 543
 			$dbType = 'primary' ;
541
-		}
542
-		elseif($field->type->db == 'boolean'){
544
+		} elseif($field->type->db == 'boolean'){
543 545
 			$dbType = 'primary' ;
544
-		}
545
-		elseif($field->type->db == 'text'){
546
+		} elseif($field->type->db == 'text'){
546 547
 			$dbType = 'string' ;
547
-		}
548
-		else {
548
+		} else {
549 549
 			$dbType = $field->type->db ;
550 550
 		}
551 551
 
552 552
 		if(array_key_exists($dbType, $this->conditionsStub)){
553 553
 			return $this->conditionsStub[$dbType];
554
-		}
555
-		else {
554
+		} else {
556 555
 			$this->conditionsStub[$dbType] = File::get($this->stubsDirectory . 'SearchConditions/'. ucwords($dbType). '.php');;
557 556
 
558 557
 			return $this->conditionsStub[$dbType];
@@ -598,12 +597,13 @@  discard block
 block discarded – undo
598 597
 		foreach ($this->modelData->reverseRelationships as $relationship)
599 598
 		{
600 599
 			$functionName = '';
601
-			if ($relationship->type == "hasOne")
602
-				$functionName = strtolower($relationship->modelName);
603
-			elseif ($relationship->type == "belongsToMany") 
604
-				$functionName = CamelCase::pluralize(strtolower($relationship->relatedTable));
605
-			else 
606
-				$functionName = CamelCase::pluralize(strtolower($relationship->modelName));
600
+			if ($relationship->type == "hasOne") {
601
+							$functionName = strtolower($relationship->modelName);
602
+			} elseif ($relationship->type == "belongsToMany") {
603
+							$functionName = CamelCase::pluralize(strtolower($relationship->relatedTable));
604
+			} else {
605
+							$functionName = CamelCase::pluralize(strtolower($relationship->modelName));
606
+			}
607 607
 
608 608
 			$replacedMethod = '';
609 609
 			$replacedMethod = str_replace('{{function_name}}', $functionName, $method);
@@ -656,20 +656,15 @@  discard block
 block discarded – undo
656 656
 			
657 657
 			if($field->index == 'primary'){
658 658
 				$dbType = 'primaryKey' ;
659
-			}
660
-			elseif($field->foreignKey){
659
+			} elseif($field->foreignKey){
661 660
 				$dbType = 'primary' ;
662
-			}
663
-			elseif($field->type->db == 'enum'){
661
+			} elseif($field->type->db == 'enum'){
664 662
 				$dbType = 'primary' ;
665
-			}
666
-			elseif($field->type->db == 'boolean'){
663
+			} elseif($field->type->db == 'boolean'){
667 664
 				$dbType = 'primary' ;
668
-			}
669
-			elseif($field->type->db == 'text'){
665
+			} elseif($field->type->db == 'text'){
670 666
 				$dbType = 'string' ;
671
-			}
672
-			else {
667
+			} else {
673 668
 				$dbType = $field->type->db ;
674 669
 			}
675 670
 			
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/Core/MigrationCompiler.php 1 patch
Braces   +19 added lines, -16 removed lines patch added patch discarded remove patch
@@ -68,12 +68,15 @@  discard block
 block discarded – undo
68 68
 		{
69 69
 			$parsedModifiers = '';
70 70
 
71
-			if($field->index == "primary")
72
-				continue ;
73
-			if($this->modelData->timeStamps && $field->name == "created_at")
74
-				continue ;
75
-			if($this->modelData->timeStamps && $field->name == "updated_at")
76
-				continue ;
71
+			if($field->index == "primary") {
72
+							continue ;
73
+			}
74
+			if($this->modelData->timeStamps && $field->name == "created_at") {
75
+							continue ;
76
+			}
77
+			if($this->modelData->timeStamps && $field->name == "updated_at") {
78
+							continue ;
79
+			}
77 80
 
78 81
 			// Check modifiers
79 82
 			if (!empty($field->modifiers))
@@ -87,8 +90,7 @@  discard block
 block discarded – undo
87 90
 					if (count($modifierAndValue) == 2)
88 91
 					{
89 92
 						$parsedModifiers .= '->' . $modifierAndValue[0] . '(' . $modifierAndValue[1] . ')';
90
-					}
91
-					else
93
+					} else
92 94
 					{
93 95
 						$parsedModifiers .= '->' . $modifierAndValue[0] . '()';
94 96
 					}
@@ -105,21 +107,21 @@  discard block
 block discarded – undo
105 107
 			if ($field->index != 'none')
106 108
 			{
107 109
 				$fields .= sprintf("\t\t\t\$table->%s('%s')%s->%s();" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers, $field->index);
108
-			}
109
-			else
110
+			} else
110 111
 			{
111 112
 				if ($field->type->db == "enum") {
112 113
 					$items = '';
113 114
 					foreach ($field->options as $key => $option) {
114 115
 						$items .= "'" . $option . "'";
115
-						if ($key < (count($field->options) - 1))
116
-							$items .= ", ";
116
+						if ($key < (count($field->options) - 1)) {
117
+													$items .= ", ";
118
+						}
117 119
 					}
118 120
 
119 121
 					$fields .= sprintf("\t\t\t\$table->%s('%s', array(%s));" . PHP_EOL, $field->type->db, $field->name, $items);
122
+				} else {
123
+									$fields .= sprintf("\t\t\t\$table->%s('%s')%s;" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers);
120 124
 				}
121
-				else
122
-					$fields .= sprintf("\t\t\t\$table->%s('%s')%s;" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers);
123 125
 			}
124 126
 
125 127
 			// Check foreign key
@@ -129,8 +131,9 @@  discard block
 block discarded – undo
129 131
 			}
130 132
 		}
131 133
 
132
-		if($this->modelData->timeStamps)
133
-			$fields .= PHP_EOL . "\t\t\t\$table->timestamps();" . PHP_EOL;
134
+		if($this->modelData->timeStamps) {
135
+					$fields .= PHP_EOL . "\t\t\t\$table->timestamps();" . PHP_EOL;
136
+		}
134 137
 
135 138
 		$this->stub = str_replace('{{fields}}', $fields, $this->stub);
136 139
 
Please login to merge, or discard this patch.
src/Scaffolder/Compilers/Core/ControllerCompiler.php 1 patch
Braces   +21 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
 	
16 16
 	public function __construct($scaffolderConfig, $modelData = null, $stubName = null)
17 17
 	{
18
-		if ($stubName)
19
-			$this->stubFilename = $stubName;
18
+		if ($stubName) {
19
+					$this->stubFilename = $stubName;
20
+		}
20 21
 		$this->stubsDirectory = __DIR__ . '/../../../../stubs/Api/';
21 22
 		parent::__construct($scaffolderConfig, $modelData);
22 23
 	}
@@ -223,20 +224,15 @@  discard block
 block discarded – undo
223 224
 			
224 225
 			if($field->index == 'primary'){
225 226
 				$dbType = 'primaryKey' ;
226
-			}
227
-			elseif($field->foreignKey){
227
+			} elseif($field->foreignKey){
228 228
 				$dbType = 'primary' ;
229
-			}
230
-			elseif($field->type->db == 'enum'){
229
+			} elseif($field->type->db == 'enum'){
231 230
 				$dbType = 'primary' ;
232
-			}
233
-			elseif($field->type->db == 'boolean'){
231
+			} elseif($field->type->db == 'boolean'){
234 232
 				$dbType = 'primary' ;
235
-			}
236
-			elseif($field->type->db == 'text'){
233
+			} elseif($field->type->db == 'text'){
237 234
 				$dbType = 'string' ;
238
-			}
239
-			else {
235
+			} else {
240 236
 				$dbType = $field->type->db ;
241 237
 			}
242 238
 			
@@ -282,12 +278,13 @@  discard block
 block discarded – undo
282 278
 		foreach ($this->modelData->reverseRelationships as $relationship)
283 279
 		{
284 280
 			$functionName = '';
285
-			if ($relationship->type == "hasOne")
286
-				$functionName = strtolower($relationship->modelName);
287
-			elseif ($relationship->type == "belongsToMany") 
288
-				$functionName = CamelCase::pluralize(strtolower($relationship->relatedTable));
289
-			else 
290
-				$functionName = CamelCase::pluralize(strtolower($relationship->modelName));
281
+			if ($relationship->type == "hasOne") {
282
+							$functionName = strtolower($relationship->modelName);
283
+			} elseif ($relationship->type == "belongsToMany") {
284
+							$functionName = CamelCase::pluralize(strtolower($relationship->relatedTable));
285
+			} else {
286
+							$functionName = CamelCase::pluralize(strtolower($relationship->modelName));
287
+			}
291 288
 
292 289
 			$replacedMethod = '';
293 290
 			$replacedMethod = str_replace('{{function_name}}', $functionName, $method);
@@ -478,27 +475,21 @@  discard block
 block discarded – undo
478 475
 		
479 476
 		if($field->index == 'primary'){
480 477
 			$dbType = 'primary' ;
481
-		}
482
-		elseif($field->foreignKey){
478
+		} elseif($field->foreignKey){
483 479
 			$dbType = 'primary' ;
484
-		}
485
-		elseif($field->type->db == 'enum'){
480
+		} elseif($field->type->db == 'enum'){
486 481
 			$dbType = 'primary' ;
487
-		}
488
-		elseif($field->type->db == 'boolean'){
482
+		} elseif($field->type->db == 'boolean'){
489 483
 			$dbType = 'primary' ;
490
-		}
491
-		elseif($field->type->db == 'text'){
484
+		} elseif($field->type->db == 'text'){
492 485
 			$dbType = 'string' ;
493
-		}
494
-		else {
486
+		} else {
495 487
 			$dbType = $field->type->db ;
496 488
 		}
497 489
 
498 490
 		if(array_key_exists($dbType, $this->conditionsStub)){
499 491
 			return $this->conditionsStub[$dbType];
500
-		}
501
-		else {
492
+		} else {
502 493
 			$this->conditionsStub[$dbType] = File::get($this->stubsDirectory . 'SearchConditions/'. ucwords($dbType). '.php');;
503 494
 
504 495
 			return $this->conditionsStub[$dbType];
Please login to merge, or discard this patch.