@@ -44,7 +44,7 @@ |
||
44 | 44 | echo"---------------------".PHP_EOL; |
45 | 45 | RajaOngkir::cachingProvince(); |
46 | 46 | echo PHP_EOL."---------------------".PHP_EOL; |
47 | - sleep(1);//Cooling Down |
|
47 | + sleep(1); //Cooling Down |
|
48 | 48 | echo"City Caching".PHP_EOL; |
49 | 49 | echo "---------------------".PHP_EOL; |
50 | 50 | RajaOngkir::cachingCity(); |
@@ -43,13 +43,13 @@ |
||
43 | 43 | echo"Refresh Cache".PHP_EOL; |
44 | 44 | echo"---------------------".PHP_EOL; |
45 | 45 | ROCache::clearCache(); |
46 | - sleep(1);//Cooling Down |
|
46 | + sleep(1); //Cooling Down |
|
47 | 47 | echo PHP_EOL."---------------------".PHP_EOL; |
48 | 48 | echo"Province Caching".PHP_EOL; |
49 | 49 | echo"---------------------".PHP_EOL; |
50 | 50 | RajaOngkir::cachingProvince(); |
51 | 51 | echo PHP_EOL."---------------------".PHP_EOL; |
52 | - sleep(1);//Cooling Down |
|
52 | + sleep(1); //Cooling Down |
|
53 | 53 | echo"City Caching".PHP_EOL; |
54 | 54 | echo "---------------------".PHP_EOL; |
55 | 55 | RajaOngkir::cachingCity(); |
@@ -13,13 +13,13 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('ro_city', function (Blueprint $table) { |
|
17 | - $table->string('city_id',20)->primary(); |
|
18 | - $table->string('province_id',20); |
|
19 | - $table->string('province',120)->nullable(); |
|
20 | - $table->string('type',60)->nullable(); |
|
21 | - $table->string('city_name',128)->nullable(); |
|
22 | - $table->string('postal_code',15)->nullable(); |
|
16 | + Schema::create('ro_city', function(Blueprint $table) { |
|
17 | + $table->string('city_id', 20)->primary(); |
|
18 | + $table->string('province_id', 20); |
|
19 | + $table->string('province', 120)->nullable(); |
|
20 | + $table->string('type', 60)->nullable(); |
|
21 | + $table->string('city_name', 128)->nullable(); |
|
22 | + $table->string('postal_code', 15)->nullable(); |
|
23 | 23 | $table->timestamps(); |
24 | 24 | |
25 | 25 | }); |
@@ -13,9 +13,9 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('ro_province', function (Blueprint $table) { |
|
17 | - $table->string('province_id',20)->primary(); |
|
18 | - $table->string('province',255)->nullable(); |
|
16 | + Schema::create('ro_province', function(Blueprint $table) { |
|
17 | + $table->string('province_id', 20)->primary(); |
|
18 | + $table->string('province', 255)->nullable(); |
|
19 | 19 | $table->timestamps(); |
20 | 20 | }); |
21 | 21 | } |
@@ -46,6 +46,6 @@ |
||
46 | 46 | $base = log($size, 1024); |
47 | 47 | $suffixes = array('B', 'KB', 'MB', 'GB', 'TB'); |
48 | 48 | |
49 | - return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)]; |
|
49 | + return round(pow(1024, $base - floor($base)), $precision).' '.$suffixes[floor($base)]; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | \ No newline at end of file |
@@ -25,16 +25,16 @@ |
||
25 | 25 | { |
26 | 26 | |
27 | 27 | $this->publishes([ |
28 | - __DIR__.'/../resources/config/irfa/rajaongkir.php' => config_path('irfa/rajaongkir.php')],'raja-ongkir'); |
|
28 | + __DIR__.'/../resources/config/irfa/rajaongkir.php' => config_path('irfa/rajaongkir.php')], 'raja-ongkir'); |
|
29 | 29 | |
30 | 30 | $this->publishes([ |
31 | 31 | __DIR__.'/../database/migrations/' => database_path('migrations') |
32 | 32 | ], 'raja-ongkir'); |
33 | 33 | |
34 | - $this->publishes([ __DIR__.'/../database/migrations/' => database_path('migrations') |
|
34 | + $this->publishes([__DIR__.'/../database/migrations/' => database_path('migrations') |
|
35 | 35 | ], 'raja-ongkir'); |
36 | 36 | |
37 | - $this->publishes([ __DIR__.'/../console/' => app_path('console') |
|
37 | + $this->publishes([__DIR__.'/../console/' => app_path('console') |
|
38 | 38 | ], 'raja-ongkir'); |
39 | 39 | |
40 | 40 |
@@ -114,41 +114,41 @@ discard block |
||
114 | 114 | echo "Can't connect to server, please check your internet connection."; |
115 | 115 | exit(); |
116 | 116 | } else { |
117 | - $json = json_decode($response,false)->rajaongkir; |
|
118 | - if($json->status->code == "400"){ |
|
117 | + $json = json_decode($response, false)->rajaongkir; |
|
118 | + if ($json->status->code == "400") { |
|
119 | 119 | throw new Exception($json->status->description); |
120 | - } else{ |
|
120 | + } else { |
|
121 | 121 | $res = $json->results; |
122 | 122 | return $res; |
123 | 123 | } |
124 | 124 | } |
125 | 125 | } |
126 | - protected static function get_courier($arr){ |
|
126 | + protected static function get_courier($arr) { |
|
127 | 127 | $origin = $arr['origin']; |
128 | 128 | $destination = $arr['destination']; |
129 | 129 | $weight = $arr['weight']; |
130 | 130 | $courier = $arr['courier']; |
131 | - $res = self::curl_cost_get($origin,$destination,$weight,$courier); |
|
131 | + $res = self::curl_cost_get($origin, $destination, $weight, $courier); |
|
132 | 132 | |
133 | 133 | return $res; |
134 | 134 | |
135 | 135 | |
136 | 136 | } |
137 | 137 | |
138 | - protected static function get_cost_details($arr){ |
|
138 | + protected static function get_cost_details($arr) { |
|
139 | 139 | $origin = $arr['origin']; |
140 | 140 | $destination = $arr['destination']; |
141 | 141 | $weight = $arr['weight']; |
142 | 142 | $courier = $arr['courier']; |
143 | - $res = self::curl_cost_get($origin,$destination,$weight,$courier); |
|
143 | + $res = self::curl_cost_get($origin, $destination, $weight, $courier); |
|
144 | 144 | |
145 | 145 | return $res{0}->costs; |
146 | 146 | } |
147 | 147 | |
148 | - private static function curl_cost_get($origin,$destination,$weight,$courier){ |
|
148 | + private static function curl_cost_get($origin, $destination, $weight, $courier) { |
|
149 | 149 | $curl = curl_init(); |
150 | 150 | |
151 | - curl_setopt_array($curl, self::curl_cost_option($origin,$destination,$weight,$courier)); |
|
151 | + curl_setopt_array($curl, self::curl_cost_option($origin, $destination, $weight, $courier)); |
|
152 | 152 | |
153 | 153 | $response = curl_exec($curl); |
154 | 154 | $err = curl_error($curl); |
@@ -159,17 +159,17 @@ discard block |
||
159 | 159 | echo "Can't connect to server, please check your internet connection."; |
160 | 160 | exit(); |
161 | 161 | } else { |
162 | - $json = json_decode($response,false)->rajaongkir; |
|
163 | - if($json->status->code == "400"){ |
|
162 | + $json = json_decode($response, false)->rajaongkir; |
|
163 | + if ($json->status->code == "400") { |
|
164 | 164 | throw new Exception($json->status->description); |
165 | - } else{ |
|
165 | + } else { |
|
166 | 166 | $res = $json->results; |
167 | 167 | return $res; |
168 | 168 | } |
169 | 169 | |
170 | 170 | } |
171 | 171 | } |
172 | - private static function curl_cost_option($origin,$destination,$weight,$courier){ |
|
172 | + private static function curl_cost_option($origin, $destination, $weight, $courier) { |
|
173 | 173 | self::setup_option(); |
174 | 174 | return array( |
175 | 175 | CURLOPT_URL => self::$url.'/cost', |
@@ -8,84 +8,84 @@ |
||
8 | 8 | use Irfa\RajaOngkir\Caching\ROCache; |
9 | 9 | use Exception; |
10 | 10 | |
11 | -class Ongkir extends Api{ |
|
11 | +class Ongkir extends Api { |
|
12 | 12 | |
13 | 13 | private static $arr; |
14 | 14 | |
15 | - public static function find($arr){ |
|
16 | - if(is_array($arr)){ |
|
15 | + public static function find($arr) { |
|
16 | + if (is_array($arr)) { |
|
17 | 17 | self::$arr = $arr; |
18 | 18 | return new static(); |
19 | - } else{ |
|
19 | + } else { |
|
20 | 20 | throw new Exception("Parameter must be an array."); |
21 | 21 | return false; |
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
25 | 25 | |
26 | - public static function cachingProvince(){ |
|
26 | + public static function cachingProvince() { |
|
27 | 27 | self::cacheProvince(); |
28 | 28 | } |
29 | - public static function cachingCity(){ |
|
29 | + public static function cachingCity() { |
|
30 | 30 | self::cacheCity(); |
31 | 31 | } |
32 | 32 | |
33 | - public static function getCostDetails(){ |
|
33 | + public static function getCostDetails() { |
|
34 | 34 | return self::get_cost_details(self::$arr); |
35 | 35 | } |
36 | 36 | |
37 | - public static function getCourier(){ |
|
37 | + public static function getCourier() { |
|
38 | 38 | return self::get_courier(self::$arr); |
39 | 39 | } |
40 | 40 | |
41 | - public static function getProvince(){ |
|
42 | - if(function_exists('config') AND function_exists('app')){ |
|
41 | + public static function getProvince() { |
|
42 | + if (function_exists('config') AND function_exists('app')) { |
|
43 | 43 | $cache_type = strtolower(config('irfa.rajaongkir.cache_type')); |
44 | - if($cache_type == 'database'){ |
|
45 | - if(ROCache::checkProv()){ |
|
46 | - if(count(ROCache::getProv(self::$arr)) > 0){ |
|
44 | + if ($cache_type == 'database') { |
|
45 | + if (ROCache::checkProv()) { |
|
46 | + if (count(ROCache::getProv(self::$arr)) > 0) { |
|
47 | 47 | $ret = ROCache::getProv(self::$arr); |
48 | - } else{ |
|
48 | + } else { |
|
49 | 49 | $ret = self::get_province(self::$arr); |
50 | 50 | } |
51 | 51 | } |
52 | - } elseif($cache_type == 'file'){ |
|
53 | - $ret = ROCache::cacheFile(config('irfa.rajaongkir.province_table'),self::$arr); |
|
54 | - if($ret == null){ |
|
52 | + } elseif ($cache_type == 'file') { |
|
53 | + $ret = ROCache::cacheFile(config('irfa.rajaongkir.province_table'), self::$arr); |
|
54 | + if ($ret == null) { |
|
55 | 55 | throw new Exception("Cache is empty."); |
56 | 56 | return false; |
57 | 57 | } |
58 | 58 | |
59 | - } else{ |
|
59 | + } else { |
|
60 | 60 | $ret = self::get_province(self::$arr); |
61 | 61 | } |
62 | - } else{ |
|
62 | + } else { |
|
63 | 63 | $ret = self::get_province(self::$arr); |
64 | 64 | } |
65 | 65 | return $ret; |
66 | 66 | } |
67 | 67 | |
68 | - public static function getCity(){ |
|
69 | - if(function_exists('config') AND function_exists('app')){ |
|
68 | + public static function getCity() { |
|
69 | + if (function_exists('config') AND function_exists('app')) { |
|
70 | 70 | $cache_type = strtolower(config('irfa.rajaongkir.cache_type')); |
71 | - if($cache_type == 'database'){ |
|
72 | - if(ROCache::checkCity()){ |
|
73 | - if(count(ROCache::getCity(self::$arr)) > 0){ |
|
71 | + if ($cache_type == 'database') { |
|
72 | + if (ROCache::checkCity()) { |
|
73 | + if (count(ROCache::getCity(self::$arr)) > 0) { |
|
74 | 74 | $ret = ROCache::getCity(self::$arr); |
75 | - } else{ |
|
75 | + } else { |
|
76 | 76 | $ret = self::get_city(self::$arr); |
77 | 77 | } |
78 | 78 | } |
79 | - } elseif($cache_type == 'file'){ |
|
80 | - $ret = ROCache::cacheFile(config('irfa.rajaongkir.city_table'),self::$arr); |
|
81 | - if($ret == null){ |
|
79 | + } elseif ($cache_type == 'file') { |
|
80 | + $ret = ROCache::cacheFile(config('irfa.rajaongkir.city_table'), self::$arr); |
|
81 | + if ($ret == null) { |
|
82 | 82 | throw new Exception("Cache is empty."); |
83 | 83 | return false; |
84 | 84 | } |
85 | - } else{ |
|
85 | + } else { |
|
86 | 86 | $ret = self::get_city(self::$arr); |
87 | 87 | } |
88 | - } else{ |
|
88 | + } else { |
|
89 | 89 | $ret = self::get_city(self::$arr); |
90 | 90 | } |
91 | 91 | return $ret; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | | Pro : http://pro.rajaongkir.com/api |
11 | 11 | | |
12 | 12 | */ |
13 | - 'account_type' => env('RAJAONGKIR_ACCOUNT_TYPE','starter'), |
|
13 | + 'account_type' => env('RAJAONGKIR_ACCOUNT_TYPE', 'starter'), |
|
14 | 14 | /* |
15 | 15 | |-------------------------------------------------------------------------- |
16 | 16 | | API key |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | | |
20 | 20 | */ |
21 | 21 | |
22 | - 'api_key' => env('RAJAONGKIR_API_KEY','your-api-key'), |
|
22 | + 'api_key' => env('RAJAONGKIR_API_KEY', 'your-api-key'), |
|
23 | 23 | /* |
24 | 24 | |-------------------------------------------------------------------------- |
25 | 25 | | For Caching |