Passed
Push — master ( ee094a...0581a6 )
by IRFA
02:19 queued 11s
created

ROCache::handle()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 16
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 16
rs 8.8333
cc 7
nc 7
nop 0
1
<?php
2
3
namespace Irfa\RajaOngkir\Console\Commands;
4
5
use Illuminate\Console\Command;
0 ignored issues
show
Bug introduced by
The type Illuminate\Console\Command 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
use Irfa\RajaOngkir\Ongkir\Ongkir as RajaOngkir;
7
8
class ROCache extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'raja-ongkir:cache {name}';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Create cache RajaOngkir';
23
24
    /**
25
     * Create a new command instance.
26
     *
27
     * @return void
28
     */
29
    public function __construct()
30
    {
31
        parent::__construct();
32
    }
33
34
    /**
35
     * Execute the console command.
36
     *
37
     * @return mixed
38
     */
39
    public function handle()
40
    {
41
        if($this->argument('name') == "all"){
42
            $this->all();
43
        } elseif($this->argument('name') == "city"){
44
            RajaOngkir::cachingCity();
45
        } elseif($this->argument('name') == "province"){
46
             RajaOngkir::cachingProvince();
47
        } elseif($this->argument('name') == "subdistrict"){
48
             RajaOngkir::cachingSubDistrict();
49
        } elseif($this->argument('name') == "clear"){
50
             ROCache::clearCache();
51
        } elseif($this->argument('name') == "refresh"){
52
             ROCache::refresh();
0 ignored issues
show
Bug Best Practice introduced by
The method Irfa\RajaOngkir\Console\...ands\ROCache::refresh() is not static, but was called statically. ( Ignorable by Annotation )

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

52
             ROCache::/** @scrutinizer ignore-call */ 
53
                      refresh();
Loading history...
53
        } else{
54
             $this->line('<fg=yellow>Valid input is  all, clear, refresh, city, province and subdistrict.');
55
        }
56
    }
57
    private function all(){
58
        echo "---------------------".PHP_EOL;
59
        echo"Province Caching".PHP_EOL;
60
        echo"---------------------".PHP_EOL;
61
        RajaOngkir::cachingProvince();
62
        echo PHP_EOL."---------------------".PHP_EOL;
63
        sleep(1);//Cooling Down
64
        echo"City Caching".PHP_EOL;
65
        echo "---------------------".PHP_EOL;
66
        RajaOngkir::cachingCity();
67
        echo PHP_EOL."---------------------".PHP_EOL;
68
        sleep(1);//Cooling Down
69
        echo"Subdistrict Caching".PHP_EOL;
70
        echo "---------------------".PHP_EOL;
71
        RajaOngkir::cachingSubDistrict();
72
        echo PHP_EOL."---------------------".PHP_EOL;
73
    }
74
    private function refresh(){
75
        echo "---------------------".PHP_EOL;
76
        echo"Refresh Cache".PHP_EOL;
77
        echo"---------------------".PHP_EOL;
78
        ROCache::clearCache();
79
        echo "---------------------".PHP_EOL;
80
        echo"Province Caching".PHP_EOL;
81
        echo"---------------------".PHP_EOL;
82
        RajaOngkir::cachingProvince();
83
        echo PHP_EOL."---------------------".PHP_EOL;
84
        sleep(1);//Cooling Down
85
        echo"City Caching".PHP_EOL;
86
        echo "---------------------".PHP_EOL;
87
        RajaOngkir::cachingCity();
88
        echo PHP_EOL."---------------------".PHP_EOL;
89
        sleep(1);//Cooling Down
90
        echo"Subdistrict Caching".PHP_EOL;
91
        echo "---------------------".PHP_EOL;
92
        RajaOngkir::cachingSubDistrict();
93
        echo PHP_EOL."---------------------".PHP_EOL;
94
    }
95
}
96