@@ -35,7 +35,7 @@ |
||
35 | 35 | break; |
36 | 36 | } |
37 | 37 | default: |
38 | - print( "error\n"); |
|
38 | + print("error\n"); |
|
39 | 39 | break; |
40 | 40 | } |
41 | 41 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | public function createRow(): string |
13 | 13 | { |
14 | - return preg_replace('/\s+/',' ',trim($this->query)); |
|
14 | + return preg_replace('/\s+/', ' ', trim($this->query)); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | public function id(): static |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | return $this; |
27 | 27 | } |
28 | 28 | |
29 | - public function string(string $name,int $limit = 255): static |
|
29 | + public function string(string $name, int $limit = 255): static |
|
30 | 30 | { |
31 | 31 | $this->query = "`$name` varchar(" . $limit . ")"; |
32 | 32 | return $this; |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | |
41 | 41 | public function timestamp(string $name): static |
42 | 42 | { |
43 | - $this->query = "`$name` timestamp"; |
|
43 | + $this->query = "`$name` timestamp"; |
|
44 | 44 | return $this; |
45 | 45 | } |
46 | 46 | |
47 | 47 | public function bigInt(string $name): static |
48 | 48 | { |
49 | - $this->query = "`$name` bigInt"; |
|
49 | + $this->query = "`$name` bigInt"; |
|
50 | 50 | return $this; |
51 | 51 | } |
52 | 52 | |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | public function foreignKey(string $name): static |
100 | 100 | { |
101 | 101 | $rand = rand(); |
102 | - $constrain = "CONSTRAINT `".$name ."_foreignKey_" .$rand . "` "; |
|
102 | + $constrain = "CONSTRAINT `" . $name . "_foreignKey_" . $rand . "` "; |
|
103 | 103 | $foreignKey = "FOREIGN KEY (`" . $name . "`)"; |
104 | 104 | $this->query = $constrain . $foreignKey; |
105 | 105 | return $this; |
106 | 106 | } |
107 | 107 | |
108 | - public function references(string $name,string $row = 'id'): static |
|
108 | + public function references(string $name, string $row = 'id'): static |
|
109 | 109 | { |
110 | 110 | $this->query .= " REFERENCES `$name` (`$row`)"; |
111 | 111 | return $this; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | public function bigInt(string $name); |
10 | 10 | |
11 | - public function string(string $name,int $limit = 255); |
|
11 | + public function string(string $name, int $limit = 255); |
|
12 | 12 | |
13 | 13 | public function integer(string $name); |
14 | 14 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | public function foreignKey(string $name); |
32 | 32 | |
33 | - public function references(string $name,string $row = 'id'); |
|
33 | + public function references(string $name, string $row = 'id'); |
|
34 | 34 | |
35 | 35 | public function cascade(); |
36 | 36 |
@@ -6,37 +6,37 @@ |
||
6 | 6 | { |
7 | 7 | |
8 | 8 | |
9 | - public function createFile(string $fileName){ |
|
10 | - if(!file_exists(CONFIG_PATH)) mkdir(CONFIG_PATH,0777,true); |
|
9 | + public function createFile(string $fileName) { |
|
10 | + if (!file_exists(CONFIG_PATH)) mkdir(CONFIG_PATH, 0777, true); |
|
11 | 11 | $fileName = ucfirst($fileName); |
12 | - if(file_exists(CONFIG_PATH ."/" .$fileName . ".php")) throw new \Exception("Arquivo ja existe"); |
|
13 | - $file = fopen(CONFIG_PATH . "/" . $fileName . ".php",'w+'); |
|
14 | - if($file){ |
|
12 | + if (file_exists(CONFIG_PATH . "/" . $fileName . ".php")) throw new \Exception("Arquivo ja existe"); |
|
13 | + $file = fopen(CONFIG_PATH . "/" . $fileName . ".php", 'w+'); |
|
14 | + if ($file) { |
|
15 | 15 | $text = $this->copyFile(); |
16 | - $lines = $this->modifyClassName($text,$fileName); |
|
17 | - fwrite($file,$lines); |
|
16 | + $lines = $this->modifyClassName($text, $fileName); |
|
17 | + fwrite($file, $lines); |
|
18 | 18 | fclose($file); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | |
22 | 22 | private function copyFile():string { |
23 | 23 | $fileNameReplace = __DIR__ . "/../ModelFile/ModelFile.php"; |
24 | - $fileCopy = fopen($fileNameReplace,'r'); |
|
25 | - $text = fread($fileCopy,filesize($fileNameReplace)); |
|
24 | + $fileCopy = fopen($fileNameReplace, 'r'); |
|
25 | + $text = fread($fileCopy, filesize($fileNameReplace)); |
|
26 | 26 | fclose($fileCopy); |
27 | 27 | return $text; |
28 | 28 | } |
29 | 29 | |
30 | - private function modifyClassName(string $text,string $fileName):string { |
|
30 | + private function modifyClassName(string $text, string $fileName):string { |
|
31 | 31 | |
32 | - $lines = explode("\n",$text); |
|
32 | + $lines = explode("\n", $text); |
|
33 | 33 | $newLines = array(); |
34 | 34 | foreach ($lines as $line) { |
35 | - $newLines[] = preg_replace('/\s+/',' ',trim($line)); |
|
35 | + $newLines[] = preg_replace('/\s+/', ' ', trim($line)); |
|
36 | 36 | } |
37 | - $searchValue = array_search("class ModelFile",$newLines); |
|
37 | + $searchValue = array_search("class ModelFile", $newLines); |
|
38 | 38 | $fileName = ucfirst($fileName); |
39 | 39 | $newLines[$searchValue] = "class $fileName"; |
40 | - return implode("\n",$newLines); |
|
40 | + return implode("\n", $newLines); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -7,9 +7,13 @@ |
||
7 | 7 | |
8 | 8 | |
9 | 9 | public function createFile(string $fileName){ |
10 | - if(!file_exists(CONFIG_PATH)) mkdir(CONFIG_PATH,0777,true); |
|
10 | + if(!file_exists(CONFIG_PATH)) { |
|
11 | + mkdir(CONFIG_PATH,0777,true); |
|
12 | + } |
|
11 | 13 | $fileName = ucfirst($fileName); |
12 | - if(file_exists(CONFIG_PATH ."/" .$fileName . ".php")) throw new \Exception("Arquivo ja existe"); |
|
14 | + if(file_exists(CONFIG_PATH ."/" .$fileName . ".php")) { |
|
15 | + throw new \Exception("Arquivo ja existe"); |
|
16 | + } |
|
13 | 17 | $file = fopen(CONFIG_PATH . "/" . $fileName . ".php",'w+'); |
14 | 18 | if($file){ |
15 | 19 | $text = $this->copyFile(); |
@@ -24,7 +24,7 @@ |
||
24 | 24 | foreach ($dir as $test) { |
25 | 25 | $array = explode('\\', $test); |
26 | 26 | foreach ($array as $value) { |
27 | - $model = $this->formatNameToObject($value); |
|
27 | + $model = $this->formatNameToObject($value); |
|
28 | 28 | $this->class_exists($model, $value); |
29 | 29 | } |
30 | 30 | } |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | -define("CONFIG_PATH",$_SERVER["PWD"] . "/database/migrations"); |
|
5 | -define("PATH_CONFIG_DB",$_SERVER["PWD"] . "/db.php"); |
|
4 | +define("CONFIG_PATH", $_SERVER["PWD"] . "/database/migrations"); |
|
5 | +define("PATH_CONFIG_DB", $_SERVER["PWD"] . "/db.php"); |
|
6 | 6 | |
7 | -define("DB_HOST","127.0.0.1"); |
|
8 | -define("DB_USER","root"); |
|
9 | -define("DB_NAME","project"); |
|
10 | -define("DB_PASSWD","root"); |
|
11 | -define("DB_OPTIONS",[ |
|
7 | +define("DB_HOST", "127.0.0.1"); |
|
8 | +define("DB_USER", "root"); |
|
9 | +define("DB_NAME", "project"); |
|
10 | +define("DB_PASSWD", "root"); |
|
11 | +define("DB_OPTIONS", [ |
|
12 | 12 | PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'", |
13 | 13 | PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, |
14 | 14 | PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, |