| Total Complexity | 10 |
| Total Lines | 71 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class Localization |
||
| 12 | { |
||
| 13 | private $region; |
||
| 14 | /** |
||
| 15 | * Method ini berfungsi untuk set tanggal dari config. |
||
| 16 | * |
||
| 17 | * @return boolean |
||
| 18 | */ |
||
| 19 | private function lang() |
||
| 28 | } |
||
| 29 | |||
| 30 | protected function regionSet($region) |
||
| 33 | } |
||
| 34 | /** |
||
| 35 | * Method ini berfungsi untuk mengambil data libur dari file json. |
||
| 36 | * |
||
| 37 | * @return boolean |
||
| 38 | */ |
||
| 39 | public function holidayData($array = true) |
||
| 40 | { |
||
| 41 | if(function_exists('resource_path')) |
||
| 42 | { |
||
| 43 | $published_file = resource_path('irfa/php-hari-libur/'.$this->lang().'.json'); |
||
| 44 | }else{ |
||
| 45 | $published_file = __DIR__.'../../../../../../resources/irfa/php-hari-libur/'.$this->lang().'.json'; |
||
| 46 | } |
||
| 47 | if(file_exists($published_file)) |
||
| 48 | { |
||
| 49 | $file = $published_file; |
||
| 50 | } else{ |
||
| 51 | $file = __DIR__.'/'.'../../Data/'.$this->lang().'.json'; |
||
| 52 | } |
||
| 53 | // dd($file); |
||
| 54 | |||
| 55 | $this->checkFile($file); |
||
| 56 | $arr = file_get_contents($file); |
||
| 57 | if($this->isJson($arr)) |
||
| 58 | { |
||
| 59 | return json_decode($arr,$array); |
||
| 60 | } else{ |
||
| 61 | throw new \Exception('Json data is invalid.'); |
||
| 62 | |||
| 63 | return false; |
||
| 64 | } |
||
| 65 | } |
||
| 66 | /** |
||
| 67 | * Method ini berfungsi untuk validasi json |
||
| 68 | * |
||
| 69 | * @return boolean |
||
| 70 | */ |
||
| 71 | private function isJson($string) { |
||
| 74 | } |
||
| 75 | |||
| 76 | private function checkFile($file) |
||
| 86 |