Issues (64)

src/Caching/CacheCurl.php (5 issues)

Labels
Severity
1
<?php
2
3
namespace Irfa\RajaOngkir\Caching;
4
5
use Illuminate\Support\Facades\Cache;
0 ignored issues
show
The type Illuminate\Support\Facades\Cache was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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'));
0 ignored issues
show
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        $cache_type = strtolower(/** @scrutinizer ignore-call */ config('irfa.rajaongkir.cache_type'));
Loading history...
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');
0 ignored issues
show
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        self::$table = /** @scrutinizer ignore-call */ config('irfa.rajaongkir.province_table');
Loading history...
41
        self::$type = 'prov';
42
        self::_import();
43
    }
44
45
    protected static function city()
46
    {
47
        self::$table = config('irfa.rajaongkir.city_table');
0 ignored issues
show
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
        self::$table = /** @scrutinizer ignore-call */ config('irfa.rajaongkir.city_table');
Loading history...
48
        self::$type = 'city';
49
        self::_import();
50
    }
51
52
    protected static function subdistrict()
53
    {
54
        self::$table = config('irfa.rajaongkir.subdistrict_table');
0 ignored issues
show
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
        self::$table = /** @scrutinizer ignore-call */ config('irfa.rajaongkir.subdistrict_table');
Loading history...
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