Passed
Push — master ( ee094a...0581a6 )
by IRFA
02:19 queued 11s
created
src/Ongkir/Ongkir.php 1 patch
Indentation   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -12,216 +12,216 @@
 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 cachingSubDistrict()
54
-    {
55
-        $get = self::cityData();
56
-        $count = count($get);
57
-        $i=0;
58
-        echo PHP_EOL."\033[42mThis may take longer, please wait.\033[0m";
59
-        foreach($get as $city){
60
-            $i++;
61
-             echo PHP_EOL."Remaining City\033[96m ".$i."/".$count."\033[0m";
62
-             echo PHP_EOL."Get Subdistrict\033[96m ".$city->city_name."...\033[0m".PHP_EOL;
63
-             self::cacheSubDistrict(['city' =>  $city->city_id]);
64
-             echo PHP_EOL;
65
-        }
66
-    }
67
-
68
-    public static function cachingCity()
69
-    {
70
-        self::cacheCity();
71
-    }
72
-
73
-    public static function costDetails()
74
-    {
75
-        self::$return = self::get_cost_details(self::$arr);
76
-
77
-        return new static();
78
-    } 
79
-    public static function testConnection()
80
-    {
81
-        self::$return = self::test_connection(self::$arr);
82
-
83
-        return new static();
84
-    }
85
-
86
-    public static function courier()
87
-    {
88
-        self::$return = self::get_courier(self::$arr);
89
-
90
-        return new static();
91
-    }
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 cachingSubDistrict()
54
+	{
55
+		$get = self::cityData();
56
+		$count = count($get);
57
+		$i=0;
58
+		echo PHP_EOL."\033[42mThis may take longer, please wait.\033[0m";
59
+		foreach($get as $city){
60
+			$i++;
61
+			 echo PHP_EOL."Remaining City\033[96m ".$i."/".$count."\033[0m";
62
+			 echo PHP_EOL."Get Subdistrict\033[96m ".$city->city_name."...\033[0m".PHP_EOL;
63
+			 self::cacheSubDistrict(['city' =>  $city->city_id]);
64
+			 echo PHP_EOL;
65
+		}
66
+	}
67
+
68
+	public static function cachingCity()
69
+	{
70
+		self::cacheCity();
71
+	}
72
+
73
+	public static function costDetails()
74
+	{
75
+		self::$return = self::get_cost_details(self::$arr);
76
+
77
+		return new static();
78
+	} 
79
+	public static function testConnection()
80
+	{
81
+		self::$return = self::test_connection(self::$arr);
82
+
83
+		return new static();
84
+	}
85
+
86
+	public static function courier()
87
+	{
88
+		self::$return = self::get_courier(self::$arr);
89
+
90
+		return new static();
91
+	}
92 92
    
93
-    public static function province()
94
-    {
95
-        $ret = self::provinceData();
96
-        self::$return = $ret;
97
-
98
-        return new static();
99
-    } 
100
-
101
-    public static function subDistrict()
102
-    {
103
-        $ret = self::subDistrictData();
104
-        self::$return = $ret;
105
-
106
-        return new static();
107
-    }
108
-    public static function internationalOrigin()
109
-    {
110
-        $ret = self::internationalOriginData();
111
-        self::$return = $ret;
112
-
113
-        return new static();
114
-    }
115
-
116
-    public static function city()
117
-    {
118
-        $ret = self::cityData();
119
-        self::$return = $ret;
120
-
121
-        return new static();
122
-    }
123
-
124
-    private static function setupConfig()
125
-    {
126
-        self::$cacheType = strtolower(config('irfa.rajaongkir.cache_type'));
127
-        self::$province = config('irfa.rajaongkir.province_table');
128
-        self::$city = config('irfa.rajaongkir.city_table');
129
-    }
130
-
131
-    private static function provinceData()
132
-    {
133
-        if (function_exists('config') && function_exists('app')) {
134
-            self::setupConfig();
135
-            $cache_type = self::$cacheType;
136
-            if ($cache_type == 'database') {
137
-                if (ROCache::checkProv()) {
138
-                    if (count(ROCache::getProv(self::$arr)) > 0) {
139
-                        $ret = ROCache::getProv(self::$arr);
140
-                    } else {
141
-                        $ret = self::get_province(self::$arr);
142
-                    }
143
-                }
144
-            } elseif ($cache_type == 'file') {
145
-                $ret = ROCache::cacheFile(self::$province, self::$arr);
146
-                if ($ret == null) {
147
-                    self::exceptionCache();
148
-                }
149
-            } else {
150
-                $ret = self::get_province(self::$arr);
151
-            }
152
-        } else {
153
-            $ret = self::get_province(self::$arr);
154
-        }
155
-
156
-        return $ret;
157
-    }
158
-    private static function subDistrictData()
159
-    {
160
-        if (function_exists('config') && function_exists('app')) {
161
-            self::setupConfig();
162
-            $cache_type = self::$cacheType;
163
-            if ($cache_type == 'database') {
164
-                if (ROCache::checkProv()) {
165
-                    if (count(ROCache::getSubdistrict(self::$arr)) > 0) {
166
-                        $ret = ROCache::getSubdistrict(self::$arr);
167
-                    } else {
168
-                        $ret = self::getSubdistrict(self::$arr);
169
-                    }
170
-                }
171
-            } elseif ($cache_type == 'file') {
172
-                $ret = ROCache::cacheFile(self::$province, self::$arr);
173
-                if ($ret == null) {
174
-                    self::exceptionCache();
175
-                }
176
-            } else {
177
-                $ret = self::getSubdistrict(self::$arr);
178
-            }
179
-        } else {
180
-            $ret = self::getSubdistrict(self::$arr);
181
-        }
182
-
183
-        return $ret;
184
-    }
185
-    private static function internationalOriginData()
186
-    {
93
+	public static function province()
94
+	{
95
+		$ret = self::provinceData();
96
+		self::$return = $ret;
97
+
98
+		return new static();
99
+	} 
100
+
101
+	public static function subDistrict()
102
+	{
103
+		$ret = self::subDistrictData();
104
+		self::$return = $ret;
105
+
106
+		return new static();
107
+	}
108
+	public static function internationalOrigin()
109
+	{
110
+		$ret = self::internationalOriginData();
111
+		self::$return = $ret;
112
+
113
+		return new static();
114
+	}
115
+
116
+	public static function city()
117
+	{
118
+		$ret = self::cityData();
119
+		self::$return = $ret;
120
+
121
+		return new static();
122
+	}
123
+
124
+	private static function setupConfig()
125
+	{
126
+		self::$cacheType = strtolower(config('irfa.rajaongkir.cache_type'));
127
+		self::$province = config('irfa.rajaongkir.province_table');
128
+		self::$city = config('irfa.rajaongkir.city_table');
129
+	}
130
+
131
+	private static function provinceData()
132
+	{
133
+		if (function_exists('config') && function_exists('app')) {
134
+			self::setupConfig();
135
+			$cache_type = self::$cacheType;
136
+			if ($cache_type == 'database') {
137
+				if (ROCache::checkProv()) {
138
+					if (count(ROCache::getProv(self::$arr)) > 0) {
139
+						$ret = ROCache::getProv(self::$arr);
140
+					} else {
141
+						$ret = self::get_province(self::$arr);
142
+					}
143
+				}
144
+			} elseif ($cache_type == 'file') {
145
+				$ret = ROCache::cacheFile(self::$province, self::$arr);
146
+				if ($ret == null) {
147
+					self::exceptionCache();
148
+				}
149
+			} else {
150
+				$ret = self::get_province(self::$arr);
151
+			}
152
+		} else {
153
+			$ret = self::get_province(self::$arr);
154
+		}
155
+
156
+		return $ret;
157
+	}
158
+	private static function subDistrictData()
159
+	{
160
+		if (function_exists('config') && function_exists('app')) {
161
+			self::setupConfig();
162
+			$cache_type = self::$cacheType;
163
+			if ($cache_type == 'database') {
164
+				if (ROCache::checkProv()) {
165
+					if (count(ROCache::getSubdistrict(self::$arr)) > 0) {
166
+						$ret = ROCache::getSubdistrict(self::$arr);
167
+					} else {
168
+						$ret = self::getSubdistrict(self::$arr);
169
+					}
170
+				}
171
+			} elseif ($cache_type == 'file') {
172
+				$ret = ROCache::cacheFile(self::$province, self::$arr);
173
+				if ($ret == null) {
174
+					self::exceptionCache();
175
+				}
176
+			} else {
177
+				$ret = self::getSubdistrict(self::$arr);
178
+			}
179
+		} else {
180
+			$ret = self::getSubdistrict(self::$arr);
181
+		}
182
+
183
+		return $ret;
184
+	}
185
+	private static function internationalOriginData()
186
+	{
187 187
         
188
-            $ret = self::get_international_origin(self::$arr);
188
+			$ret = self::get_international_origin(self::$arr);
189 189
      
190 190
 
191
-        return $ret;
192
-    }
193
-    private static function cityData()
194
-    {
195
-        if (function_exists('config') && function_exists('app')) {
196
-            self::setupConfig();
197
-            $cache_type = self::$cacheType;
198
-            if ($cache_type == 'database') {
199
-                if (ROCache::checkCity()) {
200
-                    if (count(ROCache::getCity(self::$arr)) > 0) {
201
-                        $ret = ROCache::getCity(self::$arr);
202
-                    } else {
203
-                        $ret = self::get_city(self::$arr);
204
-                    }
205
-                }
206
-            } elseif ($cache_type == 'file') {
207
-                $ret = ROCache::cacheFile(self::$city, self::$arr);
208
-                if ($ret == null) {
209
-                    self::exceptionCache();
210
-                }
211
-            } else {
212
-                $ret = self::get_city(self::$arr);
213
-            }
214
-        } else {
215
-            $ret = self::get_city(self::$arr);
216
-        }
217
-
218
-        return $ret;
219
-    }
220
-
221
-    private static function exceptionCache()
222
-    {
223
-        throw new Exception('Cache file is empty. Try php artisan raja-ongkir:cache');
224
-
225
-        return false;
226
-    }
191
+		return $ret;
192
+	}
193
+	private static function cityData()
194
+	{
195
+		if (function_exists('config') && function_exists('app')) {
196
+			self::setupConfig();
197
+			$cache_type = self::$cacheType;
198
+			if ($cache_type == 'database') {
199
+				if (ROCache::checkCity()) {
200
+					if (count(ROCache::getCity(self::$arr)) > 0) {
201
+						$ret = ROCache::getCity(self::$arr);
202
+					} else {
203
+						$ret = self::get_city(self::$arr);
204
+					}
205
+				}
206
+			} elseif ($cache_type == 'file') {
207
+				$ret = ROCache::cacheFile(self::$city, self::$arr);
208
+				if ($ret == null) {
209
+					self::exceptionCache();
210
+				}
211
+			} else {
212
+				$ret = self::get_city(self::$arr);
213
+			}
214
+		} else {
215
+			$ret = self::get_city(self::$arr);
216
+		}
217
+
218
+		return $ret;
219
+	}
220
+
221
+	private static function exceptionCache()
222
+	{
223
+		throw new Exception('Cache file is empty. Try php artisan raja-ongkir:cache');
224
+
225
+		return false;
226
+	}
227 227
 }
Please login to merge, or discard this patch.
resources/config/irfa/rajaongkir.php 1 patch
Indentation   +11 added lines, -11 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
     | API Version (for account type basic and pro)
27 27
     |--------------------------------------------------------------------------
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
     |
30 30
     */
31 31
 
32
-    'api_version' => env('RAJAONGKIR_API_VERSION', 'v2'),
33
-    /*
32
+	'api_version' => env('RAJAONGKIR_API_VERSION', 'v2'),
33
+	/*
34 34
     |--------------------------------------------------------------------------
35 35
     | For Caching
36 36
     |--------------------------------------------------------------------------
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
     | Cache supported database,and file. If you can't use cache, set value to null
43 43
     */
44 44
     
45
-    'province_table' => env('RAJAONGKIR_PROV_TABLE', 'ro_province'),
45
+	'province_table' => env('RAJAONGKIR_PROV_TABLE', 'ro_province'),
46 46
 
47
-    'city_table' => env('RAJAONGKIR_CITY_TABLE', 'ro_city'),
47
+	'city_table' => env('RAJAONGKIR_CITY_TABLE', 'ro_city'),
48 48
 
49
-    'subdistrict_table' => env('RAJAONGKIR_SUBDISTRICT_TABLE', 'ro_subdistrict'),
49
+	'subdistrict_table' => env('RAJAONGKIR_SUBDISTRICT_TABLE', 'ro_subdistrict'),
50 50
 
51
-    'cache_type' => env('RAJAONGKIR_CACHE', 'database'),
51
+	'cache_type' => env('RAJAONGKIR_CACHE', 'database'),
52 52
 
53 53
 ];
Please login to merge, or discard this patch.