Passed
Push — master ( d05f5e...a0809d )
by IRFA
02:01 queued 11s
created
src/Ongkir/Func/Api.php 1 patch
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -12,193 +12,193 @@
 block discarded – undo
12 12
 
13 13
 class Api extends CacheCurl
14 14
 {
15
-    private static $account_type;
16
-    private static $api_key;
17
-    private static $url;
18
-    private static $count = 0;
19
-
20
-    public function __construct()
21
-    {
22
-    }
23
-
24
-    private static function setup_option()
25
-    {
26
-        if (function_exists('config') and function_exists('app')) {//Load Config For Laravel
27
-            self::$account_type = strtolower(config('irfa.rajaongkir.account_type'));
28
-            self::$api_key = config('irfa.rajaongkir.api_key');
29
-        } else {//Load config For PHP Native
30
-            require __DIR__.'../../../../config/config.php';
31
-            self::$account_type = strtolower($config['account_type']);
32
-            self::$api_key = $config['api_key'];
33
-        }
34
-        if (self::$account_type == 'pro') {
35
-            self::$url = 'https://pro.rajaongkir.com/api';
36
-        } else {
37
-            self::$url = 'https://api.rajaongkir.com/'.self::$account_type;
38
-        }
39
-    }
40
-
41
-    protected static function cacheProvince()
42
-    {
43
-        self::setup_option();
44
-        echo "Retrieving data from \033[96m".self::$url."...\033[0m".PHP_EOL;
45
-        CacheCurl::caching(self::get_province())->province();
46
-    }
47
-
48
-    protected static function cacheCity()
49
-    {
50
-        self::setup_option();
51
-        echo "Retrieving data from\033[96m ".self::$url."...\033[0m".PHP_EOL;
52
-        CacheCurl::caching(self::get_city())->city();
53
-    }
54
-
55
-    protected static function get_province($arr = null)
56
-    {
57
-        if ($arr != null) {
58
-            $province_id = array_key_exists('province_id', $arr) ? '?id='.$arr['province_id'] : null;
59
-        } else {
60
-            $province_id = null;
61
-        }
62
-        self::setup_option();
63
-        $curl = curl_init();
64
-        curl_setopt_array($curl, [
65
-            CURLOPT_URL            => self::$url.'/province'.$province_id,
66
-            CURLOPT_RETURNTRANSFER => true,
67
-            CURLOPT_ENCODING       => '',
68
-            CURLOPT_MAXREDIRS      => 10,
69
-            CURLOPT_TIMEOUT        => 30,
70
-            CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
71
-            CURLOPT_CUSTOMREQUEST  => 'GET',
72
-            CURLOPT_HTTPHEADER     => [
73
-                'key: '.self::$api_key,
74
-            ],
75
-        ]);
76
-        $response = curl_exec($curl);
77
-        $err = curl_error($curl);
78
-
79
-        curl_close($curl);
80
-
81
-        if ($err) {
82
-            echo "Can't connect to server, please check your internet connection.";
83
-            exit();
84
-        } else {
85
-            $json = json_decode($response, false)->rajaongkir;
86
-            if ($json->status->code == '400') {
87
-                throw new Exception($json->status->description);
88
-            } else {
89
-                $res = $json->results;
90
-
91
-                return $res;
92
-            }
93
-        }
94
-    }
95
-
96
-    protected static function get_city($arr = null)
97
-    {
98
-        if ($arr != null) {
99
-            $province_id = array_key_exists('province_id', $arr) ? '?province='.$arr['province_id'] : null;
100
-        } else {
101
-            $province_id = null;
102
-        }
103
-        self::setup_option();
104
-        $curl = curl_init();
105
-        curl_setopt_array($curl, [
106
-            CURLOPT_URL            => self::$url.'/city'.$province_id,
107
-            CURLOPT_RETURNTRANSFER => true,
108
-            CURLOPT_ENCODING       => '',
109
-            CURLOPT_MAXREDIRS      => 10,
110
-            CURLOPT_TIMEOUT        => 30,
111
-            CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
112
-            CURLOPT_CUSTOMREQUEST  => 'GET',
113
-            CURLOPT_HTTPHEADER     => [
114
-                'key: '.self::$api_key,
115
-            ],
116
-        ]);
117
-        $response = curl_exec($curl);
118
-        $err = curl_error($curl);
119
-
120
-        curl_close($curl);
121
-
122
-        if ($err) {
123
-            echo "Can't connect to server, please check your internet connection.";
124
-            exit();
125
-        } else {
126
-            $json = json_decode($response, false)->rajaongkir;
127
-            if ($json->status->code == '400') {
128
-                throw new Exception($json->status->description);
129
-            } else {
130
-                $res = $json->results;
131
-
132
-                return $res;
133
-            }
134
-        }
135
-    }
136
-
137
-    protected static function get_courier($arr)
138
-    {
139
-        $origin = $arr['origin'];
140
-        $destination = $arr['destination'];
141
-        $weight = $arr['weight'];
142
-        $courier = $arr['courier'];
143
-        $res = self::curl_cost_get($origin, $destination, $weight, $courier);
144
-
145
-        return $res;
146
-    }
147
-
148
-    protected static function get_cost_details($arr)
149
-    {
150
-        $origin = $arr['origin'];
151
-        $destination = $arr['destination'];
152
-        $weight = $arr['weight'];
153
-        $courier = $arr['courier'];
154
-        $res = self::curl_cost_get($origin, $destination, $weight, $courier);
155
-
156
-        return $res[0]->costs;
157
-    }
158
-
159
-    private static function curl_cost_get($origin, $destination, $weight, $courier)
160
-    {
161
-        $curl = curl_init();
162
-
163
-        curl_setopt_array($curl, self::curl_cost_option($origin, $destination, $weight, $courier));
164
-
165
-        $response = curl_exec($curl);
166
-        $err = curl_error($curl);
167
-
168
-        curl_close($curl);
169
-
170
-        if ($err) {
171
-            echo "Can't connect to server, please check your internet connection.";
172
-            exit();
173
-        } else {
174
-            $json = json_decode($response, false)->rajaongkir;
175
-            if ($json->status->code == '400') {
176
-                throw new Exception($json->status->description);
177
-            } else {
178
-                $res = $json->results;
179
-
180
-                return $res;
181
-            }
182
-        }
183
-    }
184
-
185
-    private static function curl_cost_option($origin, $destination, $weight, $courier)
186
-    {
187
-        self::setup_option();
188
-
189
-        return [
190
-            CURLOPT_URL            => self::$url.'/cost',
191
-            CURLOPT_RETURNTRANSFER => true,
192
-            CURLOPT_ENCODING       => '',
193
-            CURLOPT_MAXREDIRS      => 10,
194
-            CURLOPT_TIMEOUT        => 30,
195
-            CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
196
-            CURLOPT_CUSTOMREQUEST  => 'POST',
197
-            CURLOPT_POSTFIELDS     => 'origin='.$origin.'&destination='.$destination.'&weight='.$weight.'&courier='.strtolower($courier),
198
-            CURLOPT_HTTPHEADER     => [
199
-                'content-type: application/x-www-form-urlencoded',
200
-                'key: '.self::$api_key,
201
-            ],
202
-        ];
203
-    }
15
+	private static $account_type;
16
+	private static $api_key;
17
+	private static $url;
18
+	private static $count = 0;
19
+
20
+	public function __construct()
21
+	{
22
+	}
23
+
24
+	private static function setup_option()
25
+	{
26
+		if (function_exists('config') and function_exists('app')) {//Load Config For Laravel
27
+			self::$account_type = strtolower(config('irfa.rajaongkir.account_type'));
28
+			self::$api_key = config('irfa.rajaongkir.api_key');
29
+		} else {//Load config For PHP Native
30
+			require __DIR__.'../../../../config/config.php';
31
+			self::$account_type = strtolower($config['account_type']);
32
+			self::$api_key = $config['api_key'];
33
+		}
34
+		if (self::$account_type == 'pro') {
35
+			self::$url = 'https://pro.rajaongkir.com/api';
36
+		} else {
37
+			self::$url = 'https://api.rajaongkir.com/'.self::$account_type;
38
+		}
39
+	}
40
+
41
+	protected static function cacheProvince()
42
+	{
43
+		self::setup_option();
44
+		echo "Retrieving data from \033[96m".self::$url."...\033[0m".PHP_EOL;
45
+		CacheCurl::caching(self::get_province())->province();
46
+	}
47
+
48
+	protected static function cacheCity()
49
+	{
50
+		self::setup_option();
51
+		echo "Retrieving data from\033[96m ".self::$url."...\033[0m".PHP_EOL;
52
+		CacheCurl::caching(self::get_city())->city();
53
+	}
54
+
55
+	protected static function get_province($arr = null)
56
+	{
57
+		if ($arr != null) {
58
+			$province_id = array_key_exists('province_id', $arr) ? '?id='.$arr['province_id'] : null;
59
+		} else {
60
+			$province_id = null;
61
+		}
62
+		self::setup_option();
63
+		$curl = curl_init();
64
+		curl_setopt_array($curl, [
65
+			CURLOPT_URL            => self::$url.'/province'.$province_id,
66
+			CURLOPT_RETURNTRANSFER => true,
67
+			CURLOPT_ENCODING       => '',
68
+			CURLOPT_MAXREDIRS      => 10,
69
+			CURLOPT_TIMEOUT        => 30,
70
+			CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
71
+			CURLOPT_CUSTOMREQUEST  => 'GET',
72
+			CURLOPT_HTTPHEADER     => [
73
+				'key: '.self::$api_key,
74
+			],
75
+		]);
76
+		$response = curl_exec($curl);
77
+		$err = curl_error($curl);
78
+
79
+		curl_close($curl);
80
+
81
+		if ($err) {
82
+			echo "Can't connect to server, please check your internet connection.";
83
+			exit();
84
+		} else {
85
+			$json = json_decode($response, false)->rajaongkir;
86
+			if ($json->status->code == '400') {
87
+				throw new Exception($json->status->description);
88
+			} else {
89
+				$res = $json->results;
90
+
91
+				return $res;
92
+			}
93
+		}
94
+	}
95
+
96
+	protected static function get_city($arr = null)
97
+	{
98
+		if ($arr != null) {
99
+			$province_id = array_key_exists('province_id', $arr) ? '?province='.$arr['province_id'] : null;
100
+		} else {
101
+			$province_id = null;
102
+		}
103
+		self::setup_option();
104
+		$curl = curl_init();
105
+		curl_setopt_array($curl, [
106
+			CURLOPT_URL            => self::$url.'/city'.$province_id,
107
+			CURLOPT_RETURNTRANSFER => true,
108
+			CURLOPT_ENCODING       => '',
109
+			CURLOPT_MAXREDIRS      => 10,
110
+			CURLOPT_TIMEOUT        => 30,
111
+			CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
112
+			CURLOPT_CUSTOMREQUEST  => 'GET',
113
+			CURLOPT_HTTPHEADER     => [
114
+				'key: '.self::$api_key,
115
+			],
116
+		]);
117
+		$response = curl_exec($curl);
118
+		$err = curl_error($curl);
119
+
120
+		curl_close($curl);
121
+
122
+		if ($err) {
123
+			echo "Can't connect to server, please check your internet connection.";
124
+			exit();
125
+		} else {
126
+			$json = json_decode($response, false)->rajaongkir;
127
+			if ($json->status->code == '400') {
128
+				throw new Exception($json->status->description);
129
+			} else {
130
+				$res = $json->results;
131
+
132
+				return $res;
133
+			}
134
+		}
135
+	}
136
+
137
+	protected static function get_courier($arr)
138
+	{
139
+		$origin = $arr['origin'];
140
+		$destination = $arr['destination'];
141
+		$weight = $arr['weight'];
142
+		$courier = $arr['courier'];
143
+		$res = self::curl_cost_get($origin, $destination, $weight, $courier);
144
+
145
+		return $res;
146
+	}
147
+
148
+	protected static function get_cost_details($arr)
149
+	{
150
+		$origin = $arr['origin'];
151
+		$destination = $arr['destination'];
152
+		$weight = $arr['weight'];
153
+		$courier = $arr['courier'];
154
+		$res = self::curl_cost_get($origin, $destination, $weight, $courier);
155
+
156
+		return $res[0]->costs;
157
+	}
158
+
159
+	private static function curl_cost_get($origin, $destination, $weight, $courier)
160
+	{
161
+		$curl = curl_init();
162
+
163
+		curl_setopt_array($curl, self::curl_cost_option($origin, $destination, $weight, $courier));
164
+
165
+		$response = curl_exec($curl);
166
+		$err = curl_error($curl);
167
+
168
+		curl_close($curl);
169
+
170
+		if ($err) {
171
+			echo "Can't connect to server, please check your internet connection.";
172
+			exit();
173
+		} else {
174
+			$json = json_decode($response, false)->rajaongkir;
175
+			if ($json->status->code == '400') {
176
+				throw new Exception($json->status->description);
177
+			} else {
178
+				$res = $json->results;
179
+
180
+				return $res;
181
+			}
182
+		}
183
+	}
184
+
185
+	private static function curl_cost_option($origin, $destination, $weight, $courier)
186
+	{
187
+		self::setup_option();
188
+
189
+		return [
190
+			CURLOPT_URL            => self::$url.'/cost',
191
+			CURLOPT_RETURNTRANSFER => true,
192
+			CURLOPT_ENCODING       => '',
193
+			CURLOPT_MAXREDIRS      => 10,
194
+			CURLOPT_TIMEOUT        => 30,
195
+			CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
196
+			CURLOPT_CUSTOMREQUEST  => 'POST',
197
+			CURLOPT_POSTFIELDS     => 'origin='.$origin.'&destination='.$destination.'&weight='.$weight.'&courier='.strtolower($courier),
198
+			CURLOPT_HTTPHEADER     => [
199
+				'content-type: application/x-www-form-urlencoded',
200
+				'key: '.self::$api_key,
201
+			],
202
+		];
203
+	}
204 204
 }
Please login to merge, or discard this patch.
console/commands/ROCity.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -7,37 +7,37 @@
 block discarded – undo
7 7
 
8 8
 class ROCity extends Command
9 9
 {
10
-    /**
11
-     * The name and signature of the console command.
12
-     *
13
-     * @var string
14
-     */
15
-    protected $signature = 'raja-ongkir:city-cache';
10
+	/**
11
+	 * The name and signature of the console command.
12
+	 *
13
+	 * @var string
14
+	 */
15
+	protected $signature = 'raja-ongkir:city-cache';
16 16
 
17
-    /**
18
-     * The console command description.
19
-     *
20
-     * @var string
21
-     */
22
-    protected $description = 'Create city list cache for faster loading city list';
17
+	/**
18
+	 * The console command description.
19
+	 *
20
+	 * @var string
21
+	 */
22
+	protected $description = 'Create city list cache for faster loading city list';
23 23
 
24
-    /**
25
-     * Create a new command instance.
26
-     *
27
-     * @return void
28
-     */
29
-    public function __construct()
30
-    {
31
-        parent::__construct();
32
-    }
24
+	/**
25
+	 * Create a new command instance.
26
+	 *
27
+	 * @return void
28
+	 */
29
+	public function __construct()
30
+	{
31
+		parent::__construct();
32
+	}
33 33
 
34
-    /**
35
-     * Execute the console command.
36
-     *
37
-     * @return mixed
38
-     */
39
-    public function handle()
40
-    {
41
-        RajaOngkir::cachingCity();
42
-    }
34
+	/**
35
+	 * Execute the console command.
36
+	 *
37
+	 * @return mixed
38
+	 */
39
+	public function handle()
40
+	{
41
+		RajaOngkir::cachingCity();
42
+	}
43 43
 }
Please login to merge, or discard this patch.
console/commands/RORefresh.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -8,51 +8,51 @@
 block discarded – undo
8 8
 
9 9
 class RORefresh extends Command
10 10
 {
11
-    /**
12
-     * The name and signature of the console command.
13
-     *
14
-     * @var string
15
-     */
16
-    protected $signature = 'raja-ongkir:refresh';
11
+	/**
12
+	 * The name and signature of the console command.
13
+	 *
14
+	 * @var string
15
+	 */
16
+	protected $signature = 'raja-ongkir:refresh';
17 17
 
18
-    /**
19
-     * The console command description.
20
-     *
21
-     * @var string
22
-     */
23
-    protected $description = 'Refresh Cache';
18
+	/**
19
+	 * The console command description.
20
+	 *
21
+	 * @var string
22
+	 */
23
+	protected $description = 'Refresh Cache';
24 24
 
25
-    /**
26
-     * Create a new command instance.
27
-     *
28
-     * @return void
29
-     */
30
-    public function __construct()
31
-    {
32
-        parent::__construct();
33
-    }
25
+	/**
26
+	 * Create a new command instance.
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function __construct()
31
+	{
32
+		parent::__construct();
33
+	}
34 34
 
35
-    /**
36
-     * Execute the console command.
37
-     *
38
-     * @return mixed
39
-     */
40
-    public function handle()
41
-    {
42
-        echo '---------------------'.PHP_EOL;
43
-        echo'Refresh Cache'.PHP_EOL;
44
-        echo'---------------------'.PHP_EOL;
45
-        ROCache::clearCache();
46
-        sleep(1); //Cooling Down
47
-        echo PHP_EOL.'---------------------'.PHP_EOL;
48
-        echo'Province Caching'.PHP_EOL;
49
-        echo'---------------------'.PHP_EOL;
50
-        RajaOngkir::cachingProvince();
51
-        echo PHP_EOL.'---------------------'.PHP_EOL;
52
-        sleep(1); //Cooling Down
53
-        echo'City Caching'.PHP_EOL;
54
-        echo '---------------------'.PHP_EOL;
55
-        RajaOngkir::cachingCity();
56
-        echo PHP_EOL.'---------------------'.PHP_EOL;
57
-    }
35
+	/**
36
+	 * Execute the console command.
37
+	 *
38
+	 * @return mixed
39
+	 */
40
+	public function handle()
41
+	{
42
+		echo '---------------------'.PHP_EOL;
43
+		echo'Refresh Cache'.PHP_EOL;
44
+		echo'---------------------'.PHP_EOL;
45
+		ROCache::clearCache();
46
+		sleep(1); //Cooling Down
47
+		echo PHP_EOL.'---------------------'.PHP_EOL;
48
+		echo'Province Caching'.PHP_EOL;
49
+		echo'---------------------'.PHP_EOL;
50
+		RajaOngkir::cachingProvince();
51
+		echo PHP_EOL.'---------------------'.PHP_EOL;
52
+		sleep(1); //Cooling Down
53
+		echo'City Caching'.PHP_EOL;
54
+		echo '---------------------'.PHP_EOL;
55
+		RajaOngkir::cachingCity();
56
+		echo PHP_EOL.'---------------------'.PHP_EOL;
57
+	}
58 58
 }
Please login to merge, or discard this patch.
console/commands/ROCacheAll.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -7,46 +7,46 @@
 block discarded – undo
7 7
 
8 8
 class ROCacheAll extends Command
9 9
 {
10
-    /**
11
-     * The name and signature of the console command.
12
-     *
13
-     * @var string
14
-     */
15
-    protected $signature = 'raja-ongkir:cache';
10
+	/**
11
+	 * The name and signature of the console command.
12
+	 *
13
+	 * @var string
14
+	 */
15
+	protected $signature = 'raja-ongkir:cache';
16 16
 
17
-    /**
18
-     * The console command description.
19
-     *
20
-     * @var string
21
-     */
22
-    protected $description = 'Create City and Province list cache for faster loading city and province. ';
17
+	/**
18
+	 * The console command description.
19
+	 *
20
+	 * @var string
21
+	 */
22
+	protected $description = 'Create City and Province list cache for faster loading city and province. ';
23 23
 
24
-    /**
25
-     * Create a new command instance.
26
-     *
27
-     * @return void
28
-     */
29
-    public function __construct()
30
-    {
31
-        parent::__construct();
32
-    }
24
+	/**
25
+	 * Create a new command instance.
26
+	 *
27
+	 * @return void
28
+	 */
29
+	public function __construct()
30
+	{
31
+		parent::__construct();
32
+	}
33 33
 
34
-    /**
35
-     * Execute the console command.
36
-     *
37
-     * @return mixed
38
-     */
39
-    public function handle()
40
-    {
41
-        echo '---------------------'.PHP_EOL;
42
-        echo'Province Caching'.PHP_EOL;
43
-        echo'---------------------'.PHP_EOL;
44
-        RajaOngkir::cachingProvince();
45
-        echo PHP_EOL.'---------------------'.PHP_EOL;
46
-        sleep(1); //Cooling Down
47
-        echo'City Caching'.PHP_EOL;
48
-        echo '---------------------'.PHP_EOL;
49
-        RajaOngkir::cachingCity();
50
-        echo PHP_EOL.'---------------------'.PHP_EOL;
51
-    }
34
+	/**
35
+	 * Execute the console command.
36
+	 *
37
+	 * @return mixed
38
+	 */
39
+	public function handle()
40
+	{
41
+		echo '---------------------'.PHP_EOL;
42
+		echo'Province Caching'.PHP_EOL;
43
+		echo'---------------------'.PHP_EOL;
44
+		RajaOngkir::cachingProvince();
45
+		echo PHP_EOL.'---------------------'.PHP_EOL;
46
+		sleep(1); //Cooling Down
47
+		echo'City Caching'.PHP_EOL;
48
+		echo '---------------------'.PHP_EOL;
49
+		RajaOngkir::cachingCity();
50
+		echo PHP_EOL.'---------------------'.PHP_EOL;
51
+	}
52 52
 }
Please login to merge, or discard this patch.
resources/config/irfa/rajaongkir.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 return [
4
-    /*
4
+	/*
5 5
     |--------------------------------------------------------------------------
6 6
     | End Point Api ( Server Configuration )
7 7
     |--------------------------------------------------------------------------
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
     | Pro       : http://pro.rajaongkir.com/api
12 12
     |
13 13
     */
14
-    'account_type' => env('RAJAONGKIR_ACCOUNT_TYPE', 'starter'),
15
-    /*
14
+	'account_type' => env('RAJAONGKIR_ACCOUNT_TYPE', 'starter'),
15
+	/*
16 16
     |--------------------------------------------------------------------------
17 17
     | API key
18 18
     |--------------------------------------------------------------------------
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
     |
21 21
     */
22 22
 
23
-    'api_key' => env('RAJAONGKIR_API_KEY', 'your-api-key'),
24
-    /*
23
+	'api_key' => env('RAJAONGKIR_API_KEY', 'your-api-key'),
24
+	/*
25 25
     |--------------------------------------------------------------------------
26 26
     | For Caching
27 27
     |--------------------------------------------------------------------------
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
     | Cache supported database,and file. If you can't use cache, set value to null
34 34
     */
35 35
 
36
-    'province_table' => env('RAJAONGKIR_PROV_TABLE', 'ro_province'),
36
+	'province_table' => env('RAJAONGKIR_PROV_TABLE', 'ro_province'),
37 37
 
38
-    'city_table' => env('RAJAONGKIR_CITY_TABLE', 'ro_city'),
38
+	'city_table' => env('RAJAONGKIR_CITY_TABLE', 'ro_city'),
39 39
 
40
-    'cache_type' => env('RAJAONGKIR_CACHE', null),
40
+	'cache_type' => env('RAJAONGKIR_CACHE', null),
41 41
 
42 42
 ];
Please login to merge, or discard this patch.
config/config.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-    /* Config for PHP Native */
2
+	/* Config for PHP Native */
3 3
 
4
-    $config = [
5
-        /*
4
+	$config = [
5
+		/*
6 6
     |--------------------------------------------------------------------------
7 7
     | End Point Api ( Server Configuration )
8 8
     |--------------------------------------------------------------------------
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
     | Pro : http://pro.rajaongkir.com/api
13 13
     |
14 14
     */
15
-        'account_type' => 'starter',
16
-        /*
15
+		'account_type' => 'starter',
16
+		/*
17 17
     |--------------------------------------------------------------------------
18 18
     | API key
19 19
     |--------------------------------------------------------------------------
20 20
     | You can get API key in www.rajaongkir.com
21 21
     |
22 22
     */
23
-        'api_key' => 'your-api-key',
24
-    ];
23
+		'api_key' => 'your-api-key',
24
+	];
Please login to merge, or discard this patch.
src/Ongkir/Ongkir.php 1 patch
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -12,146 +12,146 @@
 block discarded – undo
12 12
 
13 13
 class Ongkir extends Api
14 14
 {
15
-    private static $arr;
16
-    private static $return;
17
-    private static $province;
18
-    private static $city;
19
-    private static $cacheType;
20
-
21
-    public static function find($arr)
22
-    {
23
-        if (is_array($arr)) {
24
-            self::$arr = $arr;
25
-
26
-            return new static();
27
-        } else {
28
-            throw new Exception('Parameter must be an array.');
29
-
30
-            return false;
31
-        }
32
-    }
33
-
34
-    public static function get()
35
-    {
36
-        self::$arr = null; //Clear parameter
37
-        if (empty(self::$return)) {
38
-            throw new Exception('Data is not defined.');
39
-
40
-            return false;
41
-        }
42
-        $ret = self::$return;
43
-        self::$return = null;
44
-
45
-        return $ret;
46
-    }
47
-
48
-    public static function cachingProvince()
49
-    {
50
-        self::cacheProvince();
51
-    }
52
-
53
-    public static function cachingCity()
54
-    {
55
-        self::cacheCity();
56
-    }
57
-
58
-    public static function costDetails()
59
-    {
60
-        self::$return = self::get_cost_details(self::$arr);
61
-
62
-        return new static();
63
-    }
64
-
65
-    public static function courier()
66
-    {
67
-        self::$return = self::get_courier(self::$arr);
68
-
69
-        return new static();
70
-    }
71
-
72
-    public static function province()
73
-    {
74
-        $ret = self::provinceData();
75
-        self::$return = $ret;
76
-
77
-        return new static();
78
-    }
79
-
80
-    public static function city()
81
-    {
82
-        $ret = self::cityData();
83
-        self::$return = $ret;
84
-
85
-        return new static();
86
-    }
87
-
88
-    private static function setupConfig()
89
-    {
90
-        self::$cacheType = strtolower(config('irfa.rajaongkir.cache_type'));
91
-        self::$province = config('irfa.rajaongkir.province_table');
92
-        self::$city = config('irfa.rajaongkir.city_table');
93
-    }
94
-
95
-    private static function provinceData()
96
-    {
97
-        if (function_exists('config') and function_exists('app')) {
98
-            self::setupConfig();
99
-            $cache_type = self::$cacheType;
100
-            if ($cache_type == 'database') {
101
-                if (ROCache::checkProv()) {
102
-                    if (count(ROCache::getProv(self::$arr)) > 0) {
103
-                        $ret = ROCache::getProv(self::$arr);
104
-                    } else {
105
-                        $ret = self::get_province(self::$arr);
106
-                    }
107
-                }
108
-            } elseif ($cache_type == 'file') {
109
-                $ret = ROCache::cacheFile(self::$province, self::$arr);
110
-                if ($ret == null) {
111
-                    self::exceptionCache();
112
-                }
113
-            } else {
114
-                $ret = self::get_province(self::$arr);
115
-            }
116
-        } else {
117
-            $ret = self::get_province(self::$arr);
118
-        }
119
-
120
-        return $ret;
121
-    }
122
-
123
-    private static function cityData()
124
-    {
125
-        if (function_exists('config') and function_exists('app')) {
126
-            self::setupConfig();
127
-            $cache_type = self::$cacheType;
128
-            if ($cache_type == 'database') {
129
-                if (ROCache::checkCity()) {
130
-                    if (count(ROCache::getCity(self::$arr)) > 0) {
131
-                        $ret = ROCache::getCity(self::$arr);
132
-                    } else {
133
-                        $ret = self::get_city(self::$arr);
134
-                    }
135
-                }
136
-            } elseif ($cache_type == 'file') {
137
-                $ret = ROCache::cacheFile(self::$city, self::$arr);
138
-                if ($ret == null) {
139
-                    self::exceptionCache();
140
-                }
141
-            } else {
142
-                $ret = self::get_city(self::$arr);
143
-            }
144
-        } else {
145
-            $ret = self::get_city(self::$arr);
146
-        }
147
-
148
-        return $ret;
149
-    }
150
-
151
-    private static function exceptionCache()
152
-    {
153
-        throw new Exception('Cache file is empty. Try php artisan raja-ongkir:cache');
154
-
155
-        return false;
156
-    }
15
+	private static $arr;
16
+	private static $return;
17
+	private static $province;
18
+	private static $city;
19
+	private static $cacheType;
20
+
21
+	public static function find($arr)
22
+	{
23
+		if (is_array($arr)) {
24
+			self::$arr = $arr;
25
+
26
+			return new static();
27
+		} else {
28
+			throw new Exception('Parameter must be an array.');
29
+
30
+			return false;
31
+		}
32
+	}
33
+
34
+	public static function get()
35
+	{
36
+		self::$arr = null; //Clear parameter
37
+		if (empty(self::$return)) {
38
+			throw new Exception('Data is not defined.');
39
+
40
+			return false;
41
+		}
42
+		$ret = self::$return;
43
+		self::$return = null;
44
+
45
+		return $ret;
46
+	}
47
+
48
+	public static function cachingProvince()
49
+	{
50
+		self::cacheProvince();
51
+	}
52
+
53
+	public static function cachingCity()
54
+	{
55
+		self::cacheCity();
56
+	}
57
+
58
+	public static function costDetails()
59
+	{
60
+		self::$return = self::get_cost_details(self::$arr);
61
+
62
+		return new static();
63
+	}
64
+
65
+	public static function courier()
66
+	{
67
+		self::$return = self::get_courier(self::$arr);
68
+
69
+		return new static();
70
+	}
71
+
72
+	public static function province()
73
+	{
74
+		$ret = self::provinceData();
75
+		self::$return = $ret;
76
+
77
+		return new static();
78
+	}
79
+
80
+	public static function city()
81
+	{
82
+		$ret = self::cityData();
83
+		self::$return = $ret;
84
+
85
+		return new static();
86
+	}
87
+
88
+	private static function setupConfig()
89
+	{
90
+		self::$cacheType = strtolower(config('irfa.rajaongkir.cache_type'));
91
+		self::$province = config('irfa.rajaongkir.province_table');
92
+		self::$city = config('irfa.rajaongkir.city_table');
93
+	}
94
+
95
+	private static function provinceData()
96
+	{
97
+		if (function_exists('config') and function_exists('app')) {
98
+			self::setupConfig();
99
+			$cache_type = self::$cacheType;
100
+			if ($cache_type == 'database') {
101
+				if (ROCache::checkProv()) {
102
+					if (count(ROCache::getProv(self::$arr)) > 0) {
103
+						$ret = ROCache::getProv(self::$arr);
104
+					} else {
105
+						$ret = self::get_province(self::$arr);
106
+					}
107
+				}
108
+			} elseif ($cache_type == 'file') {
109
+				$ret = ROCache::cacheFile(self::$province, self::$arr);
110
+				if ($ret == null) {
111
+					self::exceptionCache();
112
+				}
113
+			} else {
114
+				$ret = self::get_province(self::$arr);
115
+			}
116
+		} else {
117
+			$ret = self::get_province(self::$arr);
118
+		}
119
+
120
+		return $ret;
121
+	}
122
+
123
+	private static function cityData()
124
+	{
125
+		if (function_exists('config') and function_exists('app')) {
126
+			self::setupConfig();
127
+			$cache_type = self::$cacheType;
128
+			if ($cache_type == 'database') {
129
+				if (ROCache::checkCity()) {
130
+					if (count(ROCache::getCity(self::$arr)) > 0) {
131
+						$ret = ROCache::getCity(self::$arr);
132
+					} else {
133
+						$ret = self::get_city(self::$arr);
134
+					}
135
+				}
136
+			} elseif ($cache_type == 'file') {
137
+				$ret = ROCache::cacheFile(self::$city, self::$arr);
138
+				if ($ret == null) {
139
+					self::exceptionCache();
140
+				}
141
+			} else {
142
+				$ret = self::get_city(self::$arr);
143
+			}
144
+		} else {
145
+			$ret = self::get_city(self::$arr);
146
+		}
147
+
148
+		return $ret;
149
+	}
150
+
151
+	private static function exceptionCache()
152
+	{
153
+		throw new Exception('Cache file is empty. Try php artisan raja-ongkir:cache');
154
+
155
+		return false;
156
+	}
157 157
 }
Please login to merge, or discard this patch.