Skip to content

Commit

Permalink
remove toolkit construct
Browse files Browse the repository at this point in the history
  • Loading branch information
ares333 committed Dec 6, 2018
1 parent 1a57c27 commit f31bb91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/HttpClone.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class HttpClone extends Toolkit
*/
function __construct($dir)
{
parent::__construct();
if (! is_dir($dir) || ! is_writable($dir)) {
user_error('dir(' . $dir . ') is invalid', E_USER_ERROR);
}
Expand Down
13 changes: 5 additions & 8 deletions src/Toolkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Toolkit
// Curl instance
protected $_curl;

function __construct(Curl $curl = null)
function setCurl(Curl $curl = null)
{
$this->_curl = $curl;
if (! isset($this->_curl)) {
Expand Down Expand Up @@ -49,8 +49,7 @@ function __construct(Curl $curl = null)
*/
function onFail($error, $args)
{
$msg = "Curl error ($error[errorCode]). $error[errorMsg], url=" .
$error['info']['url'];
$msg = "Curl error ($error[errorCode]). $error[errorMsg], url=" . $error['info']['url'];
if ($this->_curl->onInfo == array(
$this,
'onInfo'
Expand Down Expand Up @@ -123,8 +122,7 @@ function onInfo($info, $curl = null, $isLast = null)
}
$all = $info['all'];
$all['downloadSpeed'] = round($all['downloadSpeed'] / 1024) . 'KB';
$all['downloadSize'] = round(
($all['headerSize'] + $all['bodySize']) / 1024 / 1024) . "MB";
$all['downloadSize'] = round(($all['headerSize'] + $all['bodySize']) / 1024 / 1024) . "MB";
// clean
foreach (array_keys($meta) as $v) {
if (! array_key_exists($v, $all)) {
Expand Down Expand Up @@ -348,9 +346,8 @@ function buildUrl(array $parse)
$parse['query'] .= '#';
}
$parse['path'] = preg_replace('/\/+/', '/', $parse['path']);
return $parse['scheme'] . $parse['user'] . $parse['pass'] .
$parse['host'] . $parse['port'] . $parse['path'] . $parse['query'] .
$parse['fragment'];
return $parse['scheme'] . $parse['user'] . $parse['pass'] . $parse['host'] . $parse['port'] . $parse['path'] .
$parse['query'] . $parse['fragment'];
}

/**
Expand Down

0 comments on commit f31bb91

Please sign in to comment.