@@ -8,67 +8,67 @@ discard block |
||
| 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 | private static $return; |
| 15 | 15 | |
| 16 | - public static function find($arr){ |
|
| 17 | - if(is_array($arr)){ |
|
| 16 | + public static function find($arr) { |
|
| 17 | + if (is_array($arr)) { |
|
| 18 | 18 | self::$arr = $arr; |
| 19 | 19 | return new static(); |
| 20 | - } else{ |
|
| 20 | + } else { |
|
| 21 | 21 | throw new Exception("Parameter must be an array."); |
| 22 | 22 | return false; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | } |
| 26 | - public static function get(){ |
|
| 27 | - if(empty(self::$return)){ |
|
| 26 | + public static function get() { |
|
| 27 | + if (empty(self::$return)) { |
|
| 28 | 28 | throw new Exception("Data is not defined."); |
| 29 | 29 | return false; |
| 30 | 30 | }; |
| 31 | 31 | return self::$return; |
| 32 | 32 | } |
| 33 | - public static function cachingProvince(){ |
|
| 33 | + public static function cachingProvince() { |
|
| 34 | 34 | self::cacheProvince(); |
| 35 | 35 | } |
| 36 | - public static function cachingCity(){ |
|
| 36 | + public static function cachingCity() { |
|
| 37 | 37 | self::cacheCity(); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public static function costDetails(){ |
|
| 40 | + public static function costDetails() { |
|
| 41 | 41 | self::$return = self::get_cost_details(self::$arr); |
| 42 | 42 | return new static(); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public static function courier(){ |
|
| 45 | + public static function courier() { |
|
| 46 | 46 | self::$return = self::get_courier(self::$arr); |
| 47 | 47 | return new static(); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public static function province(){ |
|
| 51 | - if(function_exists('config') AND function_exists('app')){ |
|
| 50 | + public static function province() { |
|
| 51 | + if (function_exists('config') AND function_exists('app')) { |
|
| 52 | 52 | $cache_type = strtolower(config('irfa.rajaongkir.cache_type')); |
| 53 | - if($cache_type == 'database'){ |
|
| 54 | - if(ROCache::checkProv()){ |
|
| 55 | - if(count(ROCache::getProv(self::$arr)) > 0){ |
|
| 53 | + if ($cache_type == 'database') { |
|
| 54 | + if (ROCache::checkProv()) { |
|
| 55 | + if (count(ROCache::getProv(self::$arr)) > 0) { |
|
| 56 | 56 | $ret = ROCache::getProv(self::$arr); |
| 57 | - } else{ |
|
| 57 | + } else { |
|
| 58 | 58 | $ret = self::get_province(self::$arr); |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | - } elseif($cache_type == 'file'){ |
|
| 62 | - $ret = ROCache::cacheFile(config('irfa.rajaongkir.province_table'),self::$arr); |
|
| 63 | - if($ret == null){ |
|
| 61 | + } elseif ($cache_type == 'file') { |
|
| 62 | + $ret = ROCache::cacheFile(config('irfa.rajaongkir.province_table'), self::$arr); |
|
| 63 | + if ($ret == null) { |
|
| 64 | 64 | throw new Exception("Cache is empty."); |
| 65 | 65 | return false; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - } else{ |
|
| 68 | + } else { |
|
| 69 | 69 | $ret = self::get_province(self::$arr); |
| 70 | 70 | } |
| 71 | - } else{ |
|
| 71 | + } else { |
|
| 72 | 72 | $ret = self::get_province(self::$arr); |
| 73 | 73 | } |
| 74 | 74 | self::$return = $ret; |
@@ -76,27 +76,27 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public static function city(){ |
|
| 80 | - if(function_exists('config') AND function_exists('app')){ |
|
| 79 | + public static function city() { |
|
| 80 | + if (function_exists('config') AND function_exists('app')) { |
|
| 81 | 81 | $cache_type = strtolower(config('irfa.rajaongkir.cache_type')); |
| 82 | - if($cache_type == 'database'){ |
|
| 83 | - if(ROCache::checkCity()){ |
|
| 84 | - if(count(ROCache::getCity(self::$arr)) > 0){ |
|
| 82 | + if ($cache_type == 'database') { |
|
| 83 | + if (ROCache::checkCity()) { |
|
| 84 | + if (count(ROCache::getCity(self::$arr)) > 0) { |
|
| 85 | 85 | $ret = ROCache::getCity(self::$arr); |
| 86 | - } else{ |
|
| 86 | + } else { |
|
| 87 | 87 | $ret = self::get_city(self::$arr); |
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | - } elseif($cache_type == 'file'){ |
|
| 91 | - $ret = ROCache::cacheFile(config('irfa.rajaongkir.city_table'),self::$arr); |
|
| 92 | - if($ret == null){ |
|
| 90 | + } elseif ($cache_type == 'file') { |
|
| 91 | + $ret = ROCache::cacheFile(config('irfa.rajaongkir.city_table'), self::$arr); |
|
| 92 | + if ($ret == null) { |
|
| 93 | 93 | throw new Exception("Cache is empty. Try php artisan raja-ongkir:cache"); |
| 94 | 94 | return false; |
| 95 | 95 | } |
| 96 | - } else{ |
|
| 96 | + } else { |
|
| 97 | 97 | $ret = self::get_city(self::$arr); |
| 98 | 98 | } |
| 99 | - } else{ |
|
| 99 | + } else { |
|
| 100 | 100 | $ret = self::get_city(self::$arr); |
| 101 | 101 | } |
| 102 | 102 | self::$return = $ret; |