DateHelpers::lessThanDate()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 2
dl 0
loc 10
rs 10
c 0
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