Completed
Pull Request — master (#13)
by D
55:05 queued 30:11
created
src/Aspects/HttpGetRequest.php 3 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -60,6 +60,9 @@  discard block
 block discarded – undo
60 60
         }
61 61
     }
62 62
 
63
+    /**
64
+     * @param string $url
65
+     */
63 66
     public function importURL($url)
64 67
     {
65 68
         $struct = parse_url($url);
@@ -78,6 +81,11 @@  discard block
 block discarded – undo
78 81
     }
79 82
 
80 83
     // utility for __construct
84
+
85
+    /**
86
+     * @param string $key
87
+     * @param string $default
88
+     */
81 89
     private static function setOr(array $struct, $key, $default=null)
82 90
     {
83 91
         if (!empty($struct[$key])) {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public function importURL($url)
64 64
     {
65 65
         $struct = parse_url($url);
66
-        if (! $struct) throw new \InvalidArgumentException("$url is not valid URL");
66
+        if (!$struct) throw new \InvalidArgumentException("$url is not valid URL");
67 67
 
68 68
         $this->scheme = self::setOr($struct, 'scheme', $this->scheme);
69 69
         $this->host = self::setOr($struct, 'host', $this->host);
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
         $this->username = self::setOr($struct, 'user', null);
73 73
         $this->password = self::setOr($struct, 'pass', null);
74 74
 
75
-        if (! empty($struct['query'])) {
75
+        if (!empty($struct['query'])) {
76 76
             parse_str($struct['query'], $this->query);
77 77
         }
78 78
     }
79 79
 
80 80
     // utility for __construct
81
-    private static function setOr(array $struct, $key, $default=null)
81
+    private static function setOr(array $struct, $key, $default = null)
82 82
     {
83 83
         if (!empty($struct[$key])) {
84 84
             return $struct[$key];
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             CURLOPT_USERAGENT => $this->genUA(),
99 99
         );
100 100
 
101
-        $curlOpts[CURLOPT_VERBOSE] = (bool) $this->verbose;
101
+        $curlOpts[CURLOPT_VERBOSE] = (bool)$this->verbose;
102 102
 
103 103
         if ($this->username && $this->password) {
104 104
             $curlOpts[CURLOPT_USERPWD] = "$this->username:$this->password";
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
     public function importURL($url)
64 64
     {
65 65
         $struct = parse_url($url);
66
-        if (! $struct) throw new \InvalidArgumentException("$url is not valid URL");
66
+        if (! $struct) {
67
+            throw new \InvalidArgumentException("$url is not valid URL");
68
+        }
67 69
 
68 70
         $this->scheme = self::setOr($struct, 'scheme', $this->scheme);
69 71
         $this->host = self::setOr($struct, 'host', $this->host);
@@ -149,7 +151,9 @@  discard block
 block discarded – undo
149 151
 
150 152
     public static function genUA() {
151 153
         static $ua;
152
-        if ($ua) return $ua;
154
+        if ($ua) {
155
+            return $ua;
156
+        }
153 157
         $phpVersion = defined('HHVM_VERSION') ? 'HHVM ' . HHVM_VERSION : 'PHP ' . PHP_VERSION;
154 158
 
155 159
         return $ua = sprintf(
Please login to merge, or discard this patch.
src/CurlRemoteFilesystem.php 2 patches
Doc Comments   +9 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     /**
80 80
      * Get the content.
81 81
      *
82
-     * @param string $originUrl The origin URL
82
+     * @param string $origin The origin URL
83 83
      * @param string $fileUrl   The file URL
84 84
      * @param bool   $progress  Display the progression
85 85
      * @param array  $options   Additional context options
@@ -97,6 +97,11 @@  discard block
 block discarded – undo
97 97
         });
98 98
     }
99 99
 
100
+    /**
101
+     * @param string $fileUrl
102
+     * @param boolean $progress
103
+     * @param \Closure $exec
104
+     */
100 105
     protected function fetch($origin, $fileUrl, $progress, $options, $exec)
101 106
     {
102 107
         do {
@@ -216,6 +221,9 @@  discard block
 block discarded – undo
216 221
         return 0;
217 222
     }
218 223
 
224
+    /**
225
+     * @param string $fileName
226
+     */
219 227
     public static function createFile($fileName)
220 228
     {
221 229
         if (is_dir($fileName)) {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      *
57 57
      * @return bool true
58 58
      */
59
-    public function copy($origin, $fileUrl, $fileName, $progress=true, $options=array())
59
+    public function copy($origin, $fileUrl, $fileName, $progress = true, $options = array())
60 60
     {
61 61
         return $this->fetch($origin, $fileUrl, $progress, $options, function($ch, $request) use($fileName){
62 62
             $fp = $this->createFile($fileName);
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
      *
87 87
      * @return bool|string The content
88 88
      */
89
-    public function getContents($origin, $fileUrl, $progress=true, $options=array())
89
+    public function getContents($origin, $fileUrl, $progress = true, $options = array())
90 90
     {
91
-        return $this->fetch($origin, $fileUrl, $progress, $options, function($ch, $request){
91
+        return $this->fetch($origin, $fileUrl, $progress, $options, function($ch, $request) {
92 92
             // This order is important.
93 93
             curl_setopt($ch, CURLOPT_FILE, STDOUT);
94 94
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
Please login to merge, or discard this patch.
src/Plugin.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,6 @@
 block discarded – undo
11 11
 use Composer\Plugin as CPlugin;
12 12
 use Composer\EventDispatcher;
13 13
 use Composer\Package;
14
-
15 14
 use Composer\Installer;
16 15
 use Composer\DependencyResolver;
17 16
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         }
108 108
 
109 109
         $config = $this->config->get('prestissimo');
110
-        if (! is_array($config)) {
110
+        if (!is_array($config)) {
111 111
             $config = array();
112 112
         }
113 113
         $config += array(
@@ -118,16 +118,16 @@  discard block
 block discarded – undo
118 118
             'privatePackages' => array(),
119 119
         );
120 120
 
121
-        if (! is_int($config['maxConnections']) || $config['maxConnections'] < 1) {
121
+        if (!is_int($config['maxConnections']) || $config['maxConnections'] < 1) {
122 122
             $config['maxConnections'] = 6;
123 123
         }
124
-        if (! is_int($config['minConnections']) || $config['minConnections'] > $config['maxConnections']) {
124
+        if (!is_int($config['minConnections']) || $config['minConnections'] > $config['maxConnections']) {
125 125
             $config['minConnections'] = 3;
126 126
         }
127
-        if (! is_bool($config['pipeline'])) {
127
+        if (!is_bool($config['pipeline'])) {
128 128
             $config['pipeline'] = (bool)$config['pipeline'];
129 129
         }
130
-        if (! is_array($config['privatePackages'])) {
130
+        if (!is_array($config['privatePackages'])) {
131 131
             $config['privatePackages'] = (array)$config['privatePackages'];
132 132
         }
133 133
 
Please login to merge, or discard this patch.
src/Factory.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
      * @param bool $auth
47 47
      * @return resource<curl>
48 48
      */
49
-    public static function getConnection($origin, $auth=false)
49
+    public static function getConnection($origin, $auth = false)
50 50
     {
51 51
         $instance = self::getInstance();
52 52
         if ($auth) {
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * hirak/prestissimo
4
- * @author Hiraku NAKANO
5
- * @license MIT https://github.com/hirak/prestissimo
6
- */
3
+     * hirak/prestissimo
4
+     * @author Hiraku NAKANO
5
+     * @license MIT https://github.com/hirak/prestissimo
6
+     */
7 7
 namespace Hirak\Prestissimo;
8 8
 
9 9
 /**
Please login to merge, or discard this patch.
src/ParallelDownloader.php 1 patch
Braces   +15 added lines, -8 removed lines patch added patch discarded remove patch
@@ -110,24 +110,31 @@
 block discarded – undo
110 110
             }
111 111
 
112 112
             // start multi download
113
-            do $stat = curl_multi_exec($mh, $running);
114
-            while ($stat === CURLM_CALL_MULTI_PERFORM);
113
+            do {
114
+                $stat = curl_multi_exec($mh, $running);
115
+            } while ($stat === CURLM_CALL_MULTI_PERFORM);
115 116
 
116 117
             // wait for any event
117
-            do switch (curl_multi_select($mh, 5)) {
118
+            do {
119
+                switch (curl_multi_select($mh, 5)) {
118 120
                 case -1:
119 121
                     usleep(10);
120
-                    do $stat = curl_multi_exec($mh, $running);
121
-                    while ($stat === CURLM_CALL_MULTI_PERFORM);
122
+            }
123
+                    do {
124
+                        $stat = curl_multi_exec($mh, $running);
125
+                    } while ($stat === CURLM_CALL_MULTI_PERFORM);
122 126
                     continue 2;
123 127
                 case 0:
124 128
                     continue 2;
125 129
                 default:
126
-                    do $stat = curl_multi_exec($mh, $running);
127
-                    while ($stat === CURLM_CALL_MULTI_PERFORM);
130
+                    do {
131
+                        $stat = curl_multi_exec($mh, $running);
132
+                    } while ($stat === CURLM_CALL_MULTI_PERFORM);
128 133
 
129
-                    do if ($raised = curl_multi_info_read($mh, $remains)) {
134
+                    do {
135
+                        if ($raised = curl_multi_info_read($mh, $remains)) {
130 136
                         $ch = $raised['handle'];
137
+                    }
131 138
                         $errno = curl_errno($ch);
132 139
                         $info = curl_getinfo($ch);
133 140
                         curl_setopt($ch, CURLOPT_FILE, STDOUT);
Please login to merge, or discard this patch.