Completed
Push — master ( 4f2dbb...42248e )
by Alireza
02:01
created
src/Commands/HookSetupCommand.php 1 patch
Spacing   +18 added lines, -18 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 = $_SERVER['HOME'] . '/.Josh/auth.json';
45
+        $authFile = $_SERVER['HOME'].'/.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
             }
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 
71 71
             $question = new ConfirmationQuestion(
72 72
                 'Are you wanna to save this details of default ? [ Yes or No ] :',
73
-                ['yes' , 'no']
73
+                ['yes', 'no']
74 74
             );
75 75
 
76 76
             $answer = $helper->ask($input, $output, $question);
77 77
 
78
-            if($answer){
79
-                file_put_contents($authFile,json_encode([
78
+            if ($answer) {
79
+                file_put_contents($authFile, json_encode([
80 80
                     'api' => $api,
81 81
                     'username' => $username
82 82
                 ]));
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 
91 91
             $command->line("");
92 92
 
93
-            $command->line("Packagist API : ". $auth['api']);
93
+            $command->line("Packagist API : ".$auth['api']);
94 94
 
95
-            $command->line('Packagist Username : '. $auth['username']);
95
+            $command->line('Packagist Username : '.$auth['username']);
96 96
 
97 97
             $command->note(
98 98
                 'If you want change your details type `josh hook:setup --clear` '
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
             $username = $auth['username'];
104 104
         }
105 105
 
106
-        $this->sendRequest($command,$api,$username);
106
+        $this->sendRequest($command, $api, $username);
107 107
     }
108 108
 
109 109
     /**
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $package = $command->addInput('Enter your package-url');
119 119
 
120
-        if(empty(trim($package))) {
120
+        if (empty(trim($package))) {
121 121
             $command->error("Package-url is required !");
122 122
             exit;
123 123
         }
124 124
 
125 125
         $command->info("Sending request ...");
126 126
 
127
-        $data = [ 'repository' => [ 'url' => $package ] ];
127
+        $data = ['repository' => ['url' => $package]];
128 128
 
129 129
         $client = new Guzzle([
130 130
             'base_uri' => 'https://packagist.org/',
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
             ]
134 134
         ]);
135 135
 
136
-        $result = $client->post('/api/update-package?username=' . $username .
137
-            '&apiToken=' . $api,[ 'json' => $data ]);
136
+        $result = $client->post('/api/update-package?username='.$username.
137
+            '&apiToken='.$api, ['json' => $data]);
138 138
 
139 139
         $result = json_decode($result->getBody()->getContents(), true);
140 140
 
141
-        if($result['status'] !== 'success') {
141
+        if ($result['status'] !== 'success') {
142 142
             $command->error("Message : ".$result['message']." | Failed ");
143 143
             exit;
144 144
         }
Please login to merge, or discard this patch.