DateHelpers::convertDate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
/* 
3
	Author: Irfa Ardiansyah <[email protected]>
4
*/
5
namespace Irfa\HariLibur\Core;
6
7
class DateHelpers
8
{
9
10
    public function convertDate($date)
11
    {
12
    	return date('Y-m-d',strtotime($date));
13
    }
14
15
    public function convertToDayName($date)
16
	{
17
		$time = strtotime($date);
18
		$day = date('l', $time);
19
20
		return $day;
21
	}
22
23
	public function greaterThanDate($neddle, $haystack)
24
	{
25
		$b =[];
26
		foreach ($haystack as $k => $v) {
27
			if(strtotime($k) > strtotime($neddle)){
28
				$b[] = (object) ['date' => $k, 'description' => $v];
29
			}
30
		}
31
32
		return $b;
33
		
34
	}
35
36
	public function lessThanDate($neddle, $haystack)
37
	{
38
		$b =[];
39
		foreach ($haystack as $k => $v) {
40
			if(strtotime($k) < strtotime($neddle)){
41
				$b[] = (object) ['date' => $k, 'description' => $v];
42
			}
43
		}
44
45
		return $b;
46
		
47
	}
48
49
}
50