@@ -60,6 +60,9 @@ discard block |
||
| 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 |
||
| 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])) { |
@@ -63,7 +63,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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"; |
@@ -79,7 +79,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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)) { |
@@ -56,7 +56,7 @@ discard block |
||
| 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,10 +86,10 @@ discard block |
||
| 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 | 91 | $obj = $this; |
| 92 | - return $this->fetch($origin, $fileUrl, $progress, $options, function($ch, $request, &$obj){ |
|
| 92 | + return $this->fetch($origin, $fileUrl, $progress, $options, function($ch, $request, &$obj) { |
|
| 93 | 93 | // This order is important. |
| 94 | 94 | curl_setopt($ch, CURLOPT_FILE, STDOUT); |
| 95 | 95 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
@@ -46,7 +46,7 @@ |
||
| 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) { |
@@ -107,7 +107,7 @@ discard block |
||
| 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 |
||
| 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 | |