Completed
Pull Request — 3.4 (#150)
by Marc
03:08
created
src/Mouf/Database/TDBM/Utils/TDBMDaoGenerator.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		$baseBeanName = $this->getBaseBeanNameFromTableName($tableName);
93 93
 
94 94
         $connection = $this->dbConnection;
95
-        if ($connection instanceof CachedConnection){
95
+        if ($connection instanceof CachedConnection) {
96 96
             $connection->cacheService->purgeAll();
97 97
         }
98 98
 		
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @dbType '.$normalizedType.'
185 185
 	 * @dbColumn '.$column->name.'
186
-	 * @return '.($castDatesToDateTime?'\\DateTimeImmutable|null':'timestamp|null').'
186
+	 * @return '.($castDatesToDateTime ? '\\DateTimeImmutable|null' : 'timestamp|null').'
187 187
 	 */
188 188
 	public function '.$columnGetterName.'() {
189 189
 		$date = $this->__get(\''.$column->name.'\');
190 190
 		if($date === null) {
191 191
 			return null;
192 192
 		} else {
193
-			return '.($castDatesToDateTime?'new \\DateTimeImmutable':'strtotime').'($date'.($storeInUtc?'.\' UTC\'':'').');
193
+			return '.($castDatesToDateTime ? 'new \\DateTimeImmutable' : 'strtotime').'($date'.($storeInUtc ? '.\' UTC\'' : '').');
194 194
 		}
195 195
 	}
196 196
 	
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 	 * It must be provided as a PHP timestamp.
200 200
 	 *
201 201
 	 * @dbColumn '.$column->name.'
202
-	 * @param '.($castDatesToDateTime?'\\DateTimeImmutable|null':'timestamp|null').' $'.$column->name.'
202
+	 * @param '.($castDatesToDateTime ? '\\DateTimeImmutable|null' : 'timestamp|null').' $'.$column->name.'
203 203
 	 */
204
-	public function '.$columnSetterName.'('.($castDatesToDateTime?'\\DateTimeImmutable ':'').'$'.$column->name.($castDatesToDateTime?' = null':'').') {
204
+	public function '.$columnSetterName.'('.($castDatesToDateTime ? '\\DateTimeImmutable ' : '').'$'.$column->name.($castDatesToDateTime ? ' = null' : '').') {
205 205
 		if($'.$column->name.' === null) {
206 206
 			$this->__set(\''.$column->name.'\', null);
207 207
 		} else {';
@@ -312,10 +312,10 @@  discard block
 block discarded – undo
312 312
 		
313 313
 		// Now, let's implement the shortcuts to the getter of objects.
314 314
 		// Shortcuts are used to save typing. They are available only if a referenced table is referenced only once by our tables.
315
-		foreach($referencedTablesList as $referrencedTable=>$number) {
315
+		foreach ($referencedTablesList as $referrencedTable=>$number) {
316 316
 			if ($number == 1) {
317 317
 				foreach ($constraints as $array) {
318
-					if ($array['table2'] ==$referrencedTable) {
318
+					if ($array['table2'] == $referrencedTable) {
319 319
 						$columnName = $array['col1'];
320 320
 						$targetColumnName = $array['col2'];
321 321
 						break;
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 
405 405
 }";
406 406
             $this->ensureDirectoryExist($possibleFileName);
407
-			file_put_contents($possibleFileName ,$str);
407
+			file_put_contents($possibleFileName, $str);
408 408
 			@chmod($possibleFileName, 0664);
409 409
 		}
410 410
 	}
@@ -422,11 +422,11 @@  discard block
 block discarded – undo
422 422
 		foreach ($info as $index => $data) {
423 423
 			$comments = $data['column_comment'];
424 424
 			$matches = array();
425
-			if (preg_match('/@defaultSort(\((desc|asc)\))*/', $comments, $matches) != 0){
425
+			if (preg_match('/@defaultSort(\((desc|asc)\))*/', $comments, $matches) != 0) {
426 426
 				$defaultSort = $data['column_name'];
427
-				if (count($matches == 3)){
427
+				if (count($matches == 3)) {
428 428
 					$defaultSortDirection = $matches[2];
429
-				}else{
429
+				} else {
430 430
 					$defaultSortDirection = 'ASC';
431 431
 				}
432 432
 			}
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
         $possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0];
667 667
 
668 668
         $this->ensureDirectoryExist($possibleBaseFileName);
669
-		file_put_contents($possibleBaseFileName ,$str);
669
+		file_put_contents($possibleBaseFileName, $str);
670 670
 		@chmod($possibleBaseFileName, 0664);
671 671
 
672 672
         $possibleFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$className);
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 
695 695
 }";
696 696
             $this->ensureDirectoryExist($possibleFileName);
697
-			file_put_contents($possibleFileName ,$str);
697
+			file_put_contents($possibleFileName, $str);
698 698
 			@chmod($possibleFileName, 0664);
699 699
 		}
700 700
 	}
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
         $possibleFileName = $this->rootPath.$possibleFileNames[0];
768 768
 
769 769
         $this->ensureDirectoryExist($possibleFileName);
770
-		file_put_contents($possibleFileName ,$str);
770
+		file_put_contents($possibleFileName, $str);
771 771
 	}
772 772
 	
773 773
 	/**
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 	 * @return string
835 835
 	 */
836 836
 	public static function toCamelCase($str) {
837
-		$str = strtoupper(substr($str,0,1)).substr($str,1);
837
+		$str = strtoupper(substr($str, 0, 1)).substr($str, 1);
838 838
 		while (true) {
839 839
 			if (strpos($str, "_") === false && strpos($str, " ") === false)
840 840
 				break;
@@ -843,9 +843,9 @@  discard block
 block discarded – undo
843 843
 			if ($pos === false) {
844 844
 				$pos = strpos($str, " ");
845 845
 			}
846
-			$before = substr($str,0,$pos);
847
-			$after = substr($str,$pos+1);
848
-			$str = $before.strtoupper(substr($after,0,1)).substr($after,1);
846
+			$before = substr($str, 0, $pos);
847
+			$after = substr($str, $pos+1);
848
+			$str = $before.strtoupper(substr($after, 0, 1)).substr($after, 1);
849 849
 		}
850 850
 		return $str;
851 851
 	}
Please login to merge, or discard this patch.