Total Complexity | 7 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class FileCreate |
||
6 | { |
||
7 | private $arrayFilterKeys = ['create_', '_table', '_table_']; |
||
8 | |||
9 | public function createFile(string $fileName) |
||
10 | { |
||
11 | if (!file_exists(CONFIG_PATH)) { |
||
12 | mkdir(CONFIG_PATH, 0777, true); |
||
13 | } |
||
14 | |||
15 | if (file_exists(CONFIG_PATH . "/" . $fileName . ".php")) { |
||
16 | throw new \Exception("Arquivo ja existe"); |
||
17 | } |
||
18 | $file = fopen(CONFIG_PATH . "/" . $fileName . ".php", 'w+'); |
||
19 | if ($file) { |
||
|
|||
20 | $text = $this->copyFile(); |
||
21 | $lines = $this->modifyClassName($text, $fileName); |
||
22 | fwrite($file, $lines); |
||
23 | fclose($file); |
||
24 | } |
||
25 | } |
||
26 | |||
27 | private function copyFile(): string |
||
30 | } |
||
31 | |||
32 | private function modifyClassName(string $text, string $table): string |
||
39 | } |
||
40 | } |
||
41 |