1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Irfa\RajaOngkir\Caching; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Cache; |
|
|
|
|
6
|
|
|
|
7
|
|
|
class CacheCurl extends DBImport |
8
|
|
|
{ |
9
|
|
|
private static $bucket; |
10
|
|
|
private static $table; |
11
|
|
|
private static $type; |
12
|
|
|
|
13
|
|
|
protected static function caching($results) |
14
|
|
|
{ |
15
|
|
|
self::$bucket = $results; |
16
|
|
|
|
17
|
|
|
return new static(); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
private static function _import() |
21
|
|
|
{ |
22
|
|
|
$cache_type = strtolower(config('irfa.rajaongkir.cache_type')); |
|
|
|
|
23
|
|
|
if ($cache_type == 'file') { |
24
|
|
|
Cache::store('file')->put('ro-cache-'.self::$table, self::$bucket); |
25
|
|
|
echo'Cache has been created. '.self::formatBytes(strlen(serialize(Cache::get('ro-cache-'.self::$table)))); |
26
|
|
|
} elseif ($cache_type == 'database') { |
27
|
|
|
self::import(self::$table, self::$bucket, self::$type); |
28
|
|
|
} elseif ($cache_type == null) { |
29
|
|
|
echo'Please set cache type.'; |
30
|
|
|
} else { |
31
|
|
|
echo'Cache type is not supported.'; |
32
|
|
|
} |
33
|
|
|
self::$bucket = null; |
34
|
|
|
self::$type = null; |
35
|
|
|
self::$table = null; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
protected static function province() |
39
|
|
|
{ |
40
|
|
|
self::$table = config('irfa.rajaongkir.province_table'); |
|
|
|
|
41
|
|
|
self::$type = 'prov'; |
42
|
|
|
self::_import(); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
protected static function city() |
46
|
|
|
{ |
47
|
|
|
self::$table = config('irfa.rajaongkir.city_table'); |
|
|
|
|
48
|
|
|
self::$type = 'city'; |
49
|
|
|
self::_import(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
protected static function subdistrict() |
53
|
|
|
{ |
54
|
|
|
self::$table = config('irfa.rajaongkir.subdistrict_table'); |
|
|
|
|
55
|
|
|
self::$type = 'subdistrict'; |
56
|
|
|
self::_import(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
private static function formatBytes($size, $precision = 2) |
60
|
|
|
{ |
61
|
|
|
$base = log($size, 1024); |
62
|
|
|
$suffixes = ['B', 'KB', 'MB', 'GB', 'TB']; |
63
|
|
|
|
64
|
|
|
return round(pow(1024, $base - floor($base)), $precision).' '.$suffixes[floor($base)]; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths