Completed
Push — master ( 68e0a8...c4fab6 )
by Alireza
02:23
created
src/Commands/HookSetupCommand.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         $this->setName('hook:setup')
32 32
             ->setDescription('Setup hook of your packagist package');
33 33
 
34
-        $this->addOption('clear' , 'c', InputOption::VALUE_NONE, 'Clear default details');
34
+        $this->addOption('clear', 'c', InputOption::VALUE_NONE, 'Clear default details');
35 35
     }
36 36
 
37 37
     /**
@@ -40,28 +40,28 @@  discard block
 block discarded – undo
40 40
      * @param InputInterface $input
41 41
      * @param OutputInterface $output
42 42
      */
43
-    protected function execute(InputInterface $input , OutputInterface $output)
43
+    protected function execute(InputInterface $input, OutputInterface $output)
44 44
     {
45
-        $authFile = $this->getHomeDir() . '/.Josh/auth.json';
45
+        $authFile = $this->getHomeDir().'/.Josh/auth.json';
46 46
 
47
-        if($input->getOption('clear')){
47
+        if ($input->getOption('clear')) {
48 48
             unlink($authFile);
49 49
         }
50 50
 
51 51
         $command = new Style($input, $output);
52 52
 
53
-        if(! file_exists($authFile)){
53
+        if (!file_exists($authFile)) {
54 54
 
55 55
             $username = $command->addInput('Enter your packagist username');
56 56
 
57
-            if(empty($username)) {
57
+            if (empty($username)) {
58 58
                 $command->error("Packagist username is required !");
59 59
                 exit;
60 60
             }
61 61
 
62 62
             $api = $command->addInput('Enter your packagist API');
63 63
 
64
-            if(empty($api)) {
64
+            if (empty($api)) {
65 65
                 $command->error("Packagist API is required !");
66 66
                 exit;
67 67
             }
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 
76 76
             $answer = $helper->ask($input, $output, $question);
77 77
 
78
-            if($answer){
79
-                mkdir($this->getHomeDir() . "/.Josh",0777);
78
+            if ($answer) {
79
+                mkdir($this->getHomeDir()."/.Josh", 0777);
80 80
                 touch($authFile);
81
-                chmod($authFile,0777);
82
-                file_put_contents($authFile,json_encode([
81
+                chmod($authFile, 0777);
82
+                file_put_contents($authFile, json_encode([
83 83
                     'api' => $api,
84 84
                     'username' => $username
85 85
                 ]));
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
 
94 94
             $command->line("");
95 95
 
96
-            $command->line("Packagist API : ". $auth['api']);
96
+            $command->line("Packagist API : ".$auth['api']);
97 97
 
98
-            $command->line('Packagist Username : '. $auth['username']);
98
+            $command->line('Packagist Username : '.$auth['username']);
99 99
 
100 100
             $command->note(
101 101
                 'If you want change your details type `josh hook:setup --clear` '
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             $username = $auth['username'];
107 107
         }
108 108
 
109
-        $this->sendRequest($command,$api,$username);
109
+        $this->sendRequest($command, $api, $username);
110 110
     }
111 111
 
112 112
     /**
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
     {
121 121
         $package = $command->addInput('Enter your package-url');
122 122
 
123
-        if(empty(trim($package))) {
123
+        if (empty(trim($package))) {
124 124
             $command->error("Package-url is required !");
125 125
             exit;
126 126
         }
127 127
 
128 128
         $command->info("Sending request ...");
129 129
 
130
-        $data = [ 'repository' => [ 'url' => $package ] ];
130
+        $data = ['repository' => ['url' => $package]];
131 131
 
132 132
         $client = new Guzzle([
133 133
             'base_uri' => 'https://packagist.org/',
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
             ]
137 137
         ]);
138 138
 
139
-        $result = $client->post('/api/update-package?username=' . $username .
140
-            '&apiToken=' . $api,[ 'json' => $data ]);
139
+        $result = $client->post('/api/update-package?username='.$username.
140
+            '&apiToken='.$api, ['json' => $data]);
141 141
 
142 142
         $result = json_decode($result->getBody()->getContents(), true);
143 143
 
144
-        if($result['status'] !== 'success') {
144
+        if ($result['status'] !== 'success') {
145 145
             $command->error("Message : ".$result['message']." | Failed ");
146 146
             exit;
147 147
         }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function getHomeDir()
157 157
     {
158
-        if(empty($_SERVER['HOME'])){
158
+        if (empty($_SERVER['HOME'])) {
159 159
             return posix_getpwuid(posix_getuid());
160 160
         }
161 161
 
Please login to merge, or discard this patch.
src/ConsoleStyle.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     {
118 118
         if (isset($this->verbosityMap[$level])) {
119 119
             $level = $this->verbosityMap[$level];
120
-        } elseif (! is_int($level)) {
120
+        } elseif (!is_int($level)) {
121 121
             $level = $this->verbosity;
122 122
         }
123 123
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
     public function addInput($message)
128 128
     {
129
-        $this->info('>>> ' . $message . ' :');
129
+        $this->info('>>> '.$message.' :');
130 130
 
131 131
         $userHandle = fopen("php://stdin", "r");
132 132
 
Please login to merge, or discard this patch.
src/Commands/ServerSSHCommand.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Commands/ServerAddCommand.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,10 +60,10 @@
 block discarded – undo
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.");
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Commands/ServerListCommand.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.