@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | * @param InputInterface $input |
40 | 40 | * @param OutputInterface $output |
41 | 41 | */ |
42 | - protected function execute(InputInterface $input , OutputInterface $output) |
|
42 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
43 | 43 | { |
44 | 44 | $command = new Style($input, $output); |
45 | 45 | |
46 | - $file = $file = $this->getHomeDir() . "/.Josh/servers.json"; |
|
46 | + $file = $file = $this->getHomeDir()."/.Josh/servers.json"; |
|
47 | 47 | |
48 | 48 | $servers = json_decode(file_get_contents($file), true); |
49 | 49 | |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | |
57 | 57 | $currentServer = []; |
58 | 58 | |
59 | - foreach ($servers as $server){ |
|
59 | + foreach ($servers as $server) { |
|
60 | 60 | |
61 | - if ($server[0] == $serverIdOrName){ |
|
61 | + if ($server[0] == $serverIdOrName) { |
|
62 | 62 | $currentServer = $server; |
63 | - } else if ($server[1] == $serverIdOrName){ |
|
63 | + } else if ($server[1] == $serverIdOrName) { |
|
64 | 64 | $currentServer = $server; |
65 | 65 | } |
66 | 66 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function getHomeDir() |
79 | 79 | { |
80 | - if(empty($_SERVER['HOME'])){ |
|
80 | + if (empty($_SERVER['HOME'])) { |
|
81 | 81 | return posix_getpwuid(posix_getuid()); |
82 | 82 | } |
83 | 83 |
@@ -60,10 +60,10 @@ |
||
60 | 60 | $name = $input->getOption('name'); |
61 | 61 | |
62 | 62 | foreach ($servers as $server){ |
63 | - if ( $server[1] == $name ) { |
|
64 | - $command->error("Server {$name} already exists."); |
|
65 | - exit; |
|
66 | - } |
|
63 | + if ( $server[1] == $name ) { |
|
64 | + $command->error("Server {$name} already exists."); |
|
65 | + exit; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | if ( $server[2] == $ip ) { |
69 | 69 | $command->error("Server IP {$ip} already exists."); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | $this->addOption('name', 'e', InputOption::VALUE_REQUIRED, 'Server name'); |
32 | 32 | |
33 | - $this->addOption('ip', 'i', InputOption::VALUE_REQUIRED, 'Server ip address'); |
|
33 | + $this->addOption('ip', 'i', InputOption::VALUE_REQUIRED, 'Server ip address'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | * @param InputInterface $input |
40 | 40 | * @param OutputInterface $output |
41 | 41 | */ |
42 | - protected function execute(InputInterface $input , OutputInterface $output) |
|
42 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
43 | 43 | { |
44 | 44 | $command = new Style($input, $output); |
45 | 45 | |
46 | - if (! file_exists($file = $this->getHomeDir() . "/.Josh/servers.json")) { |
|
46 | + if (!file_exists($file = $this->getHomeDir()."/.Josh/servers.json")) { |
|
47 | 47 | |
48 | - if (! is_dir($dir = $this->getHomeDir() . "/.Josh")) { |
|
49 | - mkdir($dir,0777); |
|
48 | + if (!is_dir($dir = $this->getHomeDir()."/.Josh")) { |
|
49 | + mkdir($dir, 0777); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | touch($file); |
53 | - chmod($file,0777); |
|
54 | - file_put_contents($file,json_encode([])); |
|
53 | + chmod($file, 0777); |
|
54 | + file_put_contents($file, json_encode([])); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $servers = json_decode(file_get_contents($file), true); |
@@ -59,19 +59,19 @@ discard block |
||
59 | 59 | $ip = $input->getOption('ip'); |
60 | 60 | $name = $input->getOption('name'); |
61 | 61 | |
62 | - foreach ($servers as $server){ |
|
63 | - if ( $server[1] == $name ) { |
|
62 | + foreach ($servers as $server) { |
|
63 | + if ($server[1] == $name) { |
|
64 | 64 | $command->error("Server {$name} already exists."); |
65 | 65 | exit; |
66 | 66 | } |
67 | 67 | |
68 | - if ( $server[2] == $ip ) { |
|
68 | + if ($server[2] == $ip) { |
|
69 | 69 | $command->error("Server IP {$ip} already exists."); |
70 | 70 | exit; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - if(count($servers) == 0){ |
|
74 | + if (count($servers) == 0) { |
|
75 | 75 | $id = 1; |
76 | 76 | } else { |
77 | 77 | $id = array_reverse($servers)[0][0] + 1; |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | |
80 | 80 | var_dump($id); |
81 | 81 | |
82 | - $servers[] = [ $id, $name, $ip, null ]; |
|
82 | + $servers[] = [$id, $name, $ip, null]; |
|
83 | 83 | |
84 | - file_put_contents($file,json_encode($servers)); |
|
84 | + file_put_contents($file, json_encode($servers)); |
|
85 | 85 | |
86 | 86 | $command->info("Server {$name} added successfully."); |
87 | 87 | exit; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getHomeDir() |
95 | 95 | { |
96 | - if(empty($_SERVER['HOME'])){ |
|
96 | + if (empty($_SERVER['HOME'])) { |
|
97 | 97 | return posix_getpwuid(posix_getuid()); |
98 | 98 | } |
99 | 99 |
@@ -35,19 +35,19 @@ discard block |
||
35 | 35 | * @param InputInterface $input |
36 | 36 | * @param OutputInterface $output |
37 | 37 | */ |
38 | - protected function execute(InputInterface $input , OutputInterface $output) |
|
38 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
39 | 39 | { |
40 | 40 | $command = new Style($input, $output); |
41 | 41 | |
42 | - if (! file_exists($file = $this->getHomeDir() . "/.Josh/servers.json")) { |
|
42 | + if (!file_exists($file = $this->getHomeDir()."/.Josh/servers.json")) { |
|
43 | 43 | |
44 | - if (! is_dir($dir = $this->getHomeDir() . "/.Josh")) { |
|
45 | - mkdir($dir,0777); |
|
44 | + if (!is_dir($dir = $this->getHomeDir()."/.Josh")) { |
|
45 | + mkdir($dir, 0777); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | touch($file); |
49 | - chmod($file,0777); |
|
50 | - file_put_contents($file,json_encode([])); |
|
49 | + chmod($file, 0777); |
|
50 | + file_put_contents($file, json_encode([])); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $servers = json_decode(file_get_contents($file), true); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function getHomeDir() |
74 | 74 | { |
75 | - if(empty($_SERVER['HOME'])){ |
|
75 | + if (empty($_SERVER['HOME'])) { |
|
76 | 76 | return posix_getpwuid(posix_getuid()); |
77 | 77 | } |
78 | 78 |