Completed
Push — master ( c4fab6...faae25 )
by Alireza
03:17
created
src/Console.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
         try {
55 55
 
56 56
             $this->run();
57
-        } catch (\Exception $e){}
57
+        } catch (\Exception $e) {}
58 58
     }
59 59
 }
60 60
 
Please login to merge, or discard this patch.
src/helpers.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(! function_exists("package_path")){
3
+if (!function_exists("package_path")) {
4 4
 
5 5
     /**
6 6
      * Get package path
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
      */
13 13
     function package_path($path = null)
14 14
     {
15
-        if(empty($_SERVER['HOME'])){
16
-            return posix_getpwuid(posix_getuid()) . "/.Josh/" . ( is_null($path) ?: $path );
15
+        if (empty($_SERVER['HOME'])) {
16
+            return posix_getpwuid(posix_getuid())."/.Josh/".(is_null($path) ?: $path);
17 17
         }
18 18
 
19
-        return $_SERVER['HOME'] . "/.Josh/" . ( is_null($path) ?: $path );
19
+        return $_SERVER['HOME']."/.Josh/".(is_null($path) ?: $path);
20 20
     }
21 21
 }
22 22
\ No newline at end of file
Please login to merge, or discard this patch.
src/Commands/HookSetupCommand.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         $this->setName('hook:setup')
30 30
             ->setDescription('Setup hook of your packagist package');
31 31
 
32
-        $this->addOption('clear' , 'c', InputOption::VALUE_NONE, 'Clear default details');
32
+        $this->addOption('clear', 'c', InputOption::VALUE_NONE, 'Clear default details');
33 33
     }
34 34
 
35 35
     /**
@@ -38,28 +38,28 @@  discard block
 block discarded – undo
38 38
      * @param InputInterface $input
39 39
      * @param OutputInterface $output
40 40
      */
41
-    protected function execute(InputInterface $input , OutputInterface $output)
41
+    protected function execute(InputInterface $input, OutputInterface $output)
42 42
     {
43 43
         $authFile = package_path('/auth.json');
44 44
 
45
-        if($input->getOption('clear')){
45
+        if ($input->getOption('clear')) {
46 46
             unlink($authFile);
47 47
         }
48 48
 
49 49
         $command = new Style($input, $output);
50 50
 
51
-        if(! file_exists($authFile)){
51
+        if (!file_exists($authFile)) {
52 52
 
53 53
             $username = $command->addInput('Enter your packagist username');
54 54
 
55
-            if(empty($username)) {
55
+            if (empty($username)) {
56 56
                 $command->error("Packagist username is required !");
57 57
                 exit;
58 58
             }
59 59
 
60 60
             $api = $command->addInput('Enter your packagist API');
61 61
 
62
-            if(empty($api)) {
62
+            if (empty($api)) {
63 63
                 $command->error("Packagist API is required !");
64 64
                 exit;
65 65
             }
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 
74 74
             $answer = $helper->ask($input, $output, $question);
75 75
 
76
-            if($answer){
77
-                mkdir(package_path(),0777);
76
+            if ($answer) {
77
+                mkdir(package_path(), 0777);
78 78
                 touch($authFile);
79
-                chmod($authFile,0777);
80
-                file_put_contents($authFile,json_encode([
79
+                chmod($authFile, 0777);
80
+                file_put_contents($authFile, json_encode([
81 81
                     'api' => $api,
82 82
                     'username' => $username
83 83
                 ]));
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
             $auth = json_decode(file_get_contents($authFile));
89 89
 
90 90
             $command->line("");
91
-            $command->line("Packagist API : ". $auth->api);
91
+            $command->line("Packagist API : ".$auth->api);
92 92
 
93
-            $command->line('Packagist Username : '. $auth->username);
93
+            $command->line('Packagist Username : '.$auth->username);
94 94
             $command->note(
95 95
                 'If you want change your details type `josh hook:setup --clear` '
96 96
             );
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             $username = $auth->username;
100 100
         }
101 101
 
102
-        $this->sendRequest($command,$api,$username);
102
+        $this->sendRequest($command, $api, $username);
103 103
     }
104 104
 
105 105
     /**
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
     {
114 114
         $package = $command->addInput('Enter your package-url');
115 115
 
116
-        if(empty(trim($package))) {
116
+        if (empty(trim($package))) {
117 117
             $command->error("Package-url is required !");
118 118
             exit;
119 119
         }
120 120
 
121 121
         $command->info("Sending request ...");
122 122
 
123
-        $data = [ 'repository' => [ 'url' => $package ] ];
123
+        $data = ['repository' => ['url' => $package]];
124 124
 
125 125
         $client = new Guzzle([
126 126
             'base_uri' => 'https://packagist.org/',
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
             ]
130 130
         ]);
131 131
 
132
-        $result = $client->post('/api/update-package?username=' . $username .
133
-            '&apiToken=' . $api,[ 'json' => $data ]);
132
+        $result = $client->post('/api/update-package?username='.$username.
133
+            '&apiToken='.$api, ['json' => $data]);
134 134
 
135 135
         $result = json_decode($result->getBody()->getContents(), true);
136 136
 
137
-        if($result['status'] !== 'success') {
137
+        if ($result['status'] !== 'success') {
138 138
             $command->error("Message : ".$result['message']." | Failed ");
139 139
             exit;
140 140
         }
Please login to merge, or discard this patch.
src/Commands/ServerAddCommand.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 
30 30
         $this->addOption('name', 'e', InputOption::VALUE_REQUIRED, 'Server name');
31 31
 
32
-        $this->addOption('ip', 'i',  InputOption::VALUE_REQUIRED, 'Server ip address');
32
+        $this->addOption('ip', 'i', InputOption::VALUE_REQUIRED, 'Server ip address');
33 33
     }
34 34
 
35 35
     /**
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
      * @param InputInterface $input
39 39
      * @param OutputInterface $output
40 40
      */
41
-    protected function execute(InputInterface $input , OutputInterface $output)
41
+    protected function execute(InputInterface $input, OutputInterface $output)
42 42
     {
43 43
         $command = new Style($input, $output);
44 44
 
45
-        if (! file_exists($file = package_path("servers.json"))) {
45
+        if (!file_exists($file = package_path("servers.json"))) {
46 46
 
47
-            if (! is_dir($dir = package_path())) {
48
-                mkdir($dir,0777);
47
+            if (!is_dir($dir = package_path())) {
48
+                mkdir($dir, 0777);
49 49
             }
50 50
 
51 51
             touch($file);
52
-            chmod($file,0777);
53
-            file_put_contents($file,json_encode([]));
52
+            chmod($file, 0777);
53
+            file_put_contents($file, json_encode([]));
54 54
         }
55 55
 
56 56
         $servers = json_decode(file_get_contents($file), true);
@@ -58,28 +58,28 @@  discard block
 block discarded – undo
58 58
         $ip = $input->getOption('ip');
59 59
         $name = $input->getOption('name');
60 60
 
61
-        if (empty($name) || empty($ip)){
61
+        if (empty($name) || empty($ip)) {
62 62
 
63 63
             $command->error("Server name and ip address is required. use [server:add --ip=***.***.*** --name=example]");
64 64
         } else {
65 65
 
66
-            foreach ($servers as $server){
67
-                if ( $server[1] == $name ) {
66
+            foreach ($servers as $server) {
67
+                if ($server[1] == $name) {
68 68
                     $command->error("Server {$name} already exists.");
69 69
                     exit;
70 70
                 }
71 71
 
72
-                if ( $server[2] == $ip ) {
72
+                if ($server[2] == $ip) {
73 73
                     $command->error("Server IP {$ip} already exists.");
74 74
                     exit;
75 75
                 }
76 76
             }
77 77
 
78
-            $id = ( count($servers) == 0 ? 1 : array_reverse($servers)[0][0] + 1 );
78
+            $id = (count($servers) == 0 ? 1 : array_reverse($servers)[0][0] + 1);
79 79
 
80
-            $servers[] = [ $id, $name, $ip, null ];
80
+            $servers[] = [$id, $name, $ip, null];
81 81
 
82
-            file_put_contents($file,json_encode($servers));
82
+            file_put_contents($file, json_encode($servers));
83 83
 
84 84
             $command->info("Server {$name} added successfully.");
85 85
         }
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
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
      * @param InputInterface $input
38 38
      * @param OutputInterface $output
39 39
      */
40
-    protected function execute(InputInterface $input , OutputInterface $output)
40
+    protected function execute(InputInterface $input, OutputInterface $output)
41 41
     {
42 42
         $command = new Style($input, $output);
43 43
 
44
-        if(file_exists($file = $this->getHomeDir() . "/.Josh/servers.json")){
44
+        if (file_exists($file = $this->getHomeDir()."/.Josh/servers.json")) {
45 45
 
46 46
             $servers = json_decode(file_get_contents($file), true);
47 47
             $serverIdOrName = $input->getArgument('server');
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 
54 54
             $currentServer = [];
55 55
 
56
-            foreach ($servers as $server){
56
+            foreach ($servers as $server) {
57 57
 
58
-                if ($server[0] == $serverIdOrName){
58
+                if ($server[0] == $serverIdOrName) {
59 59
                     $currentServer = $server;
60
-                } else if ($server[1] == $serverIdOrName){
60
+                } else if ($server[1] == $serverIdOrName) {
61 61
                     $currentServer = $server;
62 62
                 }
63 63
             }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function getHomeDir()
80 80
     {
81
-        if(empty($_SERVER['HOME'])){
81
+        if (empty($_SERVER['HOME'])) {
82 82
             return posix_getpwuid(posix_getuid());
83 83
         }
84 84
 
Please login to merge, or discard this patch.
src/Commands/ServerListCommand.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,19 +35,19 @@
 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 = package_path("servers.json"))) {
42
+        if (!file_exists($file = package_path("servers.json"))) {
43 43
 
44
-            if (! is_dir($dir = package_path())) {
45
-                mkdir($dir,0777);
44
+            if (!is_dir($dir = package_path())) {
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);
Please login to merge, or discard this patch.