Skip to content

Commit

Permalink
return type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihtoprak committed Feb 24, 2022
1 parent f1ae125 commit 6304bdf
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/Seeders/LCSCSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ public function run()
{
ini_set('memory_limit', '-1');


$remoteJson = 'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/countries+states+cities.json';

$fileSize = $this->remoteFileSize($remoteJson);

$this->info('Fetching countries from remote source...['.$fileSize.']');


$countries = $this->remoteGet($remoteJson);
//$countries = json_decode(file_get_contents(__DIR__ . "/../countries+states+cities.json"));
foreach ($countries as $countryData) {
Expand Down Expand Up @@ -70,7 +68,6 @@ public function run()
}
$this->info("done." . PHP_EOL);
}

}

/**
Expand All @@ -79,7 +76,7 @@ public function run()
* @param [string] $url
* @return void
*/
private function remoteGet( $url ) : string
private function remoteGet( $url )
{
$ch = curl_init();

Expand All @@ -104,32 +101,23 @@ private function remoteGet( $url ) : string
private function remoteFileSize( $url )
{
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_NOBODY, TRUE);

$data = curl_exec($ch);
$size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);

curl_close($ch);


$bytes = $size;

if ($bytes > 0)
{
$unit = intval(log($bytes, 1024));
$units = array('B', 'KB', 'MB', 'GB');

if (array_key_exists($unit, $units) === true)
{
return sprintf('%d %s', $bytes / pow(1024, $unit), $units[$unit]);
}
}

return $bytes;

}

/**
Expand Down

0 comments on commit 6304bdf

Please sign in to comment.