@@ -7,12 +7,12 @@ |
||
7 | 7 | class DateHelpers |
8 | 8 | { |
9 | 9 | |
10 | - public function convertDate($date) |
|
11 | - { |
|
12 | - return date('Y-m-d',strtotime($date)); |
|
13 | - } |
|
10 | + public function convertDate($date) |
|
11 | + { |
|
12 | + return date('Y-m-d',strtotime($date)); |
|
13 | + } |
|
14 | 14 | |
15 | - public function convertToDayName($date) |
|
15 | + public function convertToDayName($date) |
|
16 | 16 | { |
17 | 17 | $time = strtotime($date); |
18 | 18 | $day = date('l', $time); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | public function convertDate($date) |
11 | 11 | { |
12 | - return date('Y-m-d',strtotime($date)); |
|
12 | + return date('Y-m-d', strtotime($date)); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | public function convertToDayName($date) |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | |
23 | 23 | public function greaterThanDate($neddle, $haystack) |
24 | 24 | { |
25 | - $b =[]; |
|
25 | + $b = []; |
|
26 | 26 | foreach ($haystack as $k => $v) { |
27 | - if(strtotime($k) > strtotime($neddle)){ |
|
27 | + if (strtotime($k) > strtotime($neddle)) { |
|
28 | 28 | $b[] = (object) ['date' => $k, 'description' => $v]; |
29 | 29 | } |
30 | 30 | } |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | |
36 | 36 | public function lessThanDate($neddle, $haystack) |
37 | 37 | { |
38 | - $b =[]; |
|
38 | + $b = []; |
|
39 | 39 | foreach ($haystack as $k => $v) { |
40 | - if(strtotime($k) < strtotime($neddle)){ |
|
40 | + if (strtotime($k) < strtotime($neddle)) { |
|
41 | 41 | $b[] = (object) ['date' => $k, 'description' => $v]; |
42 | 42 | } |
43 | 43 | } |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | { |
43 | 43 | $dt = new DateHelpers(); |
44 | 44 | |
45 | - $days = ['Saturday','Sunday']; |
|
45 | + $days = ['Saturday', 'Sunday']; |
|
46 | 46 | $day = $dt->convertToDayName($date); |
47 | - if(in_array($day, $days)) |
|
47 | + if (in_array($day, $days)) |
|
48 | 48 | { |
49 | 49 | return true; |
50 | 50 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | protected function checkOffDay($date) |
62 | 62 | { |
63 | - if($this->checkHoliday($date) || $this->checkWeekend($date)) |
|
63 | + if ($this->checkHoliday($date) || $this->checkWeekend($date)) |
|
64 | 64 | { |
65 | 65 | return true; |
66 | 66 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | protected function gettingInfo($date) |
71 | 71 | { |
72 | 72 | $this->populateHoliday(); |
73 | - if(array_key_exists($date, $this->holidays)) |
|
73 | + if (array_key_exists($date, $this->holidays)) |
|
74 | 74 | { |
75 | 75 | return $this->holidays[$date]; |
76 | 76 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | private function populateHoliday() |
81 | 81 | { |
82 | 82 | $get_holidays = $this->fetchHolidays(); |
83 | - foreach($get_holidays as $h) |
|
83 | + foreach ($get_holidays as $h) |
|
84 | 84 | { |
85 | 85 | $this->holidays[$h->date] = $h->description; |
86 | 86 | } |
@@ -8,10 +8,10 @@ |
||
8 | 8 | class ConfigLoader |
9 | 9 | { |
10 | 10 | /** |
11 | - * Method ini berfungsi memuat file konfigurasi region. |
|
12 | - * |
|
13 | - * @return string |
|
14 | - */ |
|
11 | + * Method ini berfungsi memuat file konfigurasi region. |
|
12 | + * |
|
13 | + * @return string |
|
14 | + */ |
|
15 | 15 | public function region() |
16 | 16 | { |
17 | 17 | if(file_exists(__DIR__.'../../../../../../config/irfa/hari_libur.php') && function_exists('app')){ |
@@ -14,7 +14,7 @@ |
||
14 | 14 | */ |
15 | 15 | public function region() |
16 | 16 | { |
17 | - if(file_exists(__DIR__.'../../../../../../config/irfa/hari_libur.php') && function_exists('app')){ |
|
17 | + if (file_exists(__DIR__.'../../../../../../config/irfa/hari_libur.php') && function_exists('app')) { |
|
18 | 18 | |
19 | 19 | return strtoupper(config('irfa.hari_libur.region')); |
20 | 20 |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | { |
13 | 13 | private $region; |
14 | 14 | /** |
15 | - * Method ini berfungsi untuk set tanggal dari config. |
|
16 | - * |
|
17 | - * @return boolean |
|
18 | - */ |
|
15 | + * Method ini berfungsi untuk set tanggal dari config. |
|
16 | + * |
|
17 | + * @return boolean |
|
18 | + */ |
|
19 | 19 | private function lang() |
20 | 20 | { |
21 | 21 | if(!empty($this->region)) |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | $this->region = $region; |
33 | 33 | } |
34 | 34 | /** |
35 | - * Method ini berfungsi untuk mengambil data libur dari file json. |
|
36 | - * |
|
37 | - * @return boolean |
|
38 | - */ |
|
35 | + * Method ini berfungsi untuk mengambil data libur dari file json. |
|
36 | + * |
|
37 | + * @return boolean |
|
38 | + */ |
|
39 | 39 | public function holidayData($array = true) |
40 | 40 | { |
41 | 41 | $published_file = __DIR__.'../../../../../../resources/data-libur-nasional/'.$this->lang().'.json'; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $arr = file_get_contents($file); |
51 | 51 | if($this->isJson($arr)) |
52 | 52 | { |
53 | - return json_decode($arr,$array); |
|
53 | + return json_decode($arr,$array); |
|
54 | 54 | } else{ |
55 | 55 | throw new \Exception('Json data is invalid.'); |
56 | 56 | |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | } |
59 | 59 | } |
60 | 60 | /** |
61 | - * Method ini berfungsi untuk validasi json |
|
62 | - * |
|
63 | - * @return boolean |
|
64 | - */ |
|
61 | + * Method ini berfungsi untuk validasi json |
|
62 | + * |
|
63 | + * @return boolean |
|
64 | + */ |
|
65 | 65 | private function isJson($string) { |
66 | 66 | json_decode($string); |
67 | 67 | return (json_last_error() == JSON_ERROR_NONE); |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | private function lang() |
20 | 20 | { |
21 | - if(!empty($this->region)) |
|
21 | + if (!empty($this->region)) |
|
22 | 22 | { |
23 | 23 | return strtoupper($this->region); |
24 | 24 | } |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | public function holidayData($array = true) |
40 | 40 | { |
41 | 41 | $published_file = __DIR__.'../../../../../../resources/data-libur-nasional/'.$this->lang().'.json'; |
42 | - if(file_exists($published_file)) |
|
42 | + if (file_exists($published_file)) |
|
43 | 43 | { |
44 | 44 | $file = $published_file; |
45 | - } else{ |
|
45 | + } else { |
|
46 | 46 | $file = __DIR__.'../../Data/'.$this->lang().'.json'; |
47 | 47 | } |
48 | 48 | |
49 | 49 | $this->checkFile($file); |
50 | 50 | $arr = file_get_contents($file); |
51 | - if($this->isJson($arr)) |
|
51 | + if ($this->isJson($arr)) |
|
52 | 52 | { |
53 | - return json_decode($arr,$array); |
|
54 | - } else{ |
|
53 | + return json_decode($arr, $array); |
|
54 | + } else { |
|
55 | 55 | throw new \Exception('Json data is invalid.'); |
56 | 56 | |
57 | 57 | return false; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | private function checkFile($file) |
71 | 71 | { |
72 | - if(!file_exists($file)) |
|
72 | + if (!file_exists($file)) |
|
73 | 73 | { |
74 | 74 | throw new \Exception('Region "'.$this->lang().'" is not found.'); |
75 | 75 | return false; |
@@ -13,117 +13,117 @@ |
||
13 | 13 | class HariLibur extends Libur |
14 | 14 | { |
15 | 15 | private $date; |
16 | - /** |
|
17 | - * Method ini berfungsi sebagai setter untuk $date |
|
18 | - * |
|
19 | - * @param string $date |
|
20 | - * @return object |
|
21 | - */ |
|
22 | - public function date($date) |
|
23 | - { |
|
24 | - $date_helper = new DateHelpers(); |
|
25 | - $this->date = $date_helper->convertDate($date); |
|
26 | - return $this; |
|
27 | - } |
|
16 | + /** |
|
17 | + * Method ini berfungsi sebagai setter untuk $date |
|
18 | + * |
|
19 | + * @param string $date |
|
20 | + * @return object |
|
21 | + */ |
|
22 | + public function date($date) |
|
23 | + { |
|
24 | + $date_helper = new DateHelpers(); |
|
25 | + $this->date = $date_helper->convertDate($date); |
|
26 | + return $this; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Method ini berfungsi untuk mengecek hari libur nasional |
|
31 | - * |
|
32 | - * @return boolean |
|
33 | - */ |
|
34 | - public function isHoliday() |
|
35 | - { |
|
36 | - $this->checkDate(); |
|
37 | - return $this->checkHoliday($this->date); |
|
38 | - } |
|
29 | + /** |
|
30 | + * Method ini berfungsi untuk mengecek hari libur nasional |
|
31 | + * |
|
32 | + * @return boolean |
|
33 | + */ |
|
34 | + public function isHoliday() |
|
35 | + { |
|
36 | + $this->checkDate(); |
|
37 | + return $this->checkHoliday($this->date); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Method ini berfungsi untuk mengecek akhir pekan (sabtu, minggu) |
|
42 | - * |
|
43 | - * @return boolean |
|
44 | - */ |
|
45 | - public function isWeekend() |
|
46 | - { |
|
47 | - $this->checkDate(); |
|
48 | - return $this->checkWeekend($this->date); |
|
49 | - } |
|
40 | + /** |
|
41 | + * Method ini berfungsi untuk mengecek akhir pekan (sabtu, minggu) |
|
42 | + * |
|
43 | + * @return boolean |
|
44 | + */ |
|
45 | + public function isWeekend() |
|
46 | + { |
|
47 | + $this->checkDate(); |
|
48 | + return $this->checkWeekend($this->date); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Method ini berfungsi untuk mengecek hari akhir pekan dan hari libur nasional |
|
53 | - * |
|
54 | - * @return boolean |
|
55 | - */ |
|
56 | - public function isDayOff() |
|
57 | - { |
|
58 | - $this->checkDate(); |
|
59 | - return $this->checkOffDay($this->date); |
|
60 | - } |
|
51 | + /** |
|
52 | + * Method ini berfungsi untuk mengecek hari akhir pekan dan hari libur nasional |
|
53 | + * |
|
54 | + * @return boolean |
|
55 | + */ |
|
56 | + public function isDayOff() |
|
57 | + { |
|
58 | + $this->checkDate(); |
|
59 | + return $this->checkOffDay($this->date); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Method ini berfungsi untuk mengambil data hari libur nasional |
|
64 | - * |
|
65 | - * @return object |
|
66 | - */ |
|
67 | - public function get() |
|
68 | - { |
|
69 | - return $this->fetchHolidays(); |
|
70 | - } |
|
62 | + /** |
|
63 | + * Method ini berfungsi untuk mengambil data hari libur nasional |
|
64 | + * |
|
65 | + * @return object |
|
66 | + */ |
|
67 | + public function get() |
|
68 | + { |
|
69 | + return $this->fetchHolidays(); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Method ini berfungsi untuk mengambil informasi libur |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - public function getInfo() |
|
77 | - { |
|
78 | - $this->checkDate(); |
|
79 | - return $this->gettingInfo($this->date); |
|
80 | - } |
|
72 | + /** |
|
73 | + * Method ini berfungsi untuk mengambil informasi libur |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + public function getInfo() |
|
77 | + { |
|
78 | + $this->checkDate(); |
|
79 | + return $this->gettingInfo($this->date); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Method ini berfungsi untuk mengecek tanggal sudah diisi apa belum |
|
84 | - * |
|
85 | - * @return mixed |
|
86 | - */ |
|
87 | - public function region($region) |
|
88 | - { |
|
89 | - $this->setRegion($region); |
|
90 | - return $this; |
|
91 | - } |
|
82 | + /** |
|
83 | + * Method ini berfungsi untuk mengecek tanggal sudah diisi apa belum |
|
84 | + * |
|
85 | + * @return mixed |
|
86 | + */ |
|
87 | + public function region($region) |
|
88 | + { |
|
89 | + $this->setRegion($region); |
|
90 | + return $this; |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Method ini berfungsi untuk menampilkan data libur sebelum tanggal yang telah di atur di parameter date. |
|
95 | - * |
|
96 | - * @return object |
|
97 | - */ |
|
98 | - public function nextHoliday() |
|
99 | - { |
|
100 | - $next = $this->getnextHolidays($this->date); |
|
101 | - return $next; |
|
102 | - } |
|
93 | + /** |
|
94 | + * Method ini berfungsi untuk menampilkan data libur sebelum tanggal yang telah di atur di parameter date. |
|
95 | + * |
|
96 | + * @return object |
|
97 | + */ |
|
98 | + public function nextHoliday() |
|
99 | + { |
|
100 | + $next = $this->getnextHolidays($this->date); |
|
101 | + return $next; |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Method ini berfungsi untuk menampilkan data libur setelah tanggal yang telah di atur di parameter date. |
|
106 | - * |
|
107 | - * @return object |
|
108 | - */ |
|
109 | - public function prevHoliday() |
|
110 | - { |
|
111 | - $prev = $this->getPrevHolidays($this->date); |
|
112 | - return $prev; |
|
113 | - } |
|
104 | + /** |
|
105 | + * Method ini berfungsi untuk menampilkan data libur setelah tanggal yang telah di atur di parameter date. |
|
106 | + * |
|
107 | + * @return object |
|
108 | + */ |
|
109 | + public function prevHoliday() |
|
110 | + { |
|
111 | + $prev = $this->getPrevHolidays($this->date); |
|
112 | + return $prev; |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * Method ini berfungsi untuk mengecek tanggal sudah diisi apa belum |
|
117 | - * |
|
118 | - * @return mixed |
|
119 | - */ |
|
120 | - private function checkDate() |
|
121 | - { |
|
122 | - if(empty($this->date)) |
|
123 | - { |
|
124 | - throw new \Exception('Parameter date must be provided.'); |
|
125 | - return false; |
|
126 | - } |
|
127 | - } |
|
115 | + /** |
|
116 | + * Method ini berfungsi untuk mengecek tanggal sudah diisi apa belum |
|
117 | + * |
|
118 | + * @return mixed |
|
119 | + */ |
|
120 | + private function checkDate() |
|
121 | + { |
|
122 | + if(empty($this->date)) |
|
123 | + { |
|
124 | + throw new \Exception('Parameter date must be provided.'); |
|
125 | + return false; |
|
126 | + } |
|
127 | + } |
|
128 | 128 | |
129 | 129 | } |
@@ -119,7 +119,7 @@ |
||
119 | 119 | */ |
120 | 120 | private function checkDate() |
121 | 121 | { |
122 | - if(empty($this->date)) |
|
122 | + if (empty($this->date)) |
|
123 | 123 | { |
124 | 124 | throw new \Exception('Parameter date must be provided.'); |
125 | 125 | return false; |
@@ -10,13 +10,13 @@ |
||
10 | 10 | |
11 | 11 | class HariLibur extends Facade |
12 | 12 | { |
13 | - /** |
|
14 | - * Get the registered name of the component. |
|
15 | - * |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - protected static function getFacadeAccessor() |
|
19 | - { |
|
20 | - return \Irfa\HariLibur\Func\HariLibur::class; |
|
21 | - } |
|
13 | + /** |
|
14 | + * Get the registered name of the component. |
|
15 | + * |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + protected static function getFacadeAccessor() |
|
19 | + { |
|
20 | + return \Irfa\HariLibur\Func\HariLibur::class; |
|
21 | + } |
|
22 | 22 | } |
@@ -6,26 +6,26 @@ |
||
6 | 6 | |
7 | 7 | class HariLiburServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - protected $namespace='AppLicenseServer\Controllers'; |
|
10 | - /** |
|
11 | - * Register services. |
|
12 | - * |
|
13 | - * @return void |
|
14 | - */ |
|
15 | - public function register() |
|
16 | - { |
|
9 | + protected $namespace='AppLicenseServer\Controllers'; |
|
10 | + /** |
|
11 | + * Register services. |
|
12 | + * |
|
13 | + * @return void |
|
14 | + */ |
|
15 | + public function register() |
|
16 | + { |
|
17 | 17 | |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | - /** |
|
21 | - * Bootstrap services. |
|
22 | - * |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public function boot() |
|
26 | - { |
|
27 | - $this->publishes([ |
|
28 | - __DIR__.'/../laravel-config/hari_libur.php' => config_path('irfa/hari_libur.php'), |
|
29 | - __DIR__.'/../src/Data' => resource_path('irfa/php-hari-libur'), ], 'hari-libur'); |
|
30 | - } |
|
20 | + /** |
|
21 | + * Bootstrap services. |
|
22 | + * |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public function boot() |
|
26 | + { |
|
27 | + $this->publishes([ |
|
28 | + __DIR__.'/../laravel-config/hari_libur.php' => config_path('irfa/hari_libur.php'), |
|
29 | + __DIR__.'/../src/Data' => resource_path('irfa/php-hari-libur'), ], 'hari-libur'); |
|
30 | + } |
|
31 | 31 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class HariLiburServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - protected $namespace='AppLicenseServer\Controllers'; |
|
9 | + protected $namespace = 'AppLicenseServer\Controllers'; |
|
10 | 10 | /** |
11 | 11 | * Register services. |
12 | 12 | * |