SimpleJobsSchedules   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A everyWeek() 0 3 1
A everyDay() 0 3 1
1
<?php
2
3
namespace LeKoala\SimpleJobs;
4
5
/**
6
 * A common set of schedule
7
 *
8
 * If you need more, visit http://www.cronmaker.com/
9
 *
10
 * # +--------- Minute (0-59)
11
 * # | +------- Hour (0-23)
12
 * # | | +----- Day Of Month (1-31)
13
 * # | | | +--- Month (1-12)
14
 * # | | | | +- Day Of Week (0-6) (Sunday = 0)
15
 *
16
 * Do every X intervals: *[fw_slash]X  -> Example: *[fw_slash]15 * * * *  Is every 15 minutes
17
 * Multiple Values Use Commas: 3,12,47
18
 * eg daily -> 0 0 * * *; weekly -> 0 0 * * 0; monthly ->0 0 1 * *;
19
 *
20
 * @author Koala
21
 */
22
class SimpleJobsSchedules
23
{
24
25
    // Some predefined constants or use custom methods below
26
    const EVERY_TIME = "* * * * *";
27
    const EVERY_FIVE_MIN = "*/5 * * * *";
28
    const EVERY_HOUR = "0 * * * *"; // at 1, 2, 3...
29
    const EVERY_DAY = "0 3 * * *"; // at 3 in the morning
30
    const EVERY_WEEK = "0 3 * * 1"; // on Monday (Sunday = 0 or 7)
31
    const EVERY_MONTH = "0 3 1 * *"; // first day of each month
32
    const EVERY_YEAR = "0 3 1 1 *"; // every first january
33
34
    /**
35
     * Every day on hour H
36
     *
37
     * @param int $h
38
     * @return string
39
     */
40
    public static function everyDay($h = 3)
41
    {
42
        return "0 $h * * *";
43
    }
44
45
    /**
46
     * Every week on day D (Sunday = 0 or 7) at H
47
     *
48
     * @param int $day
49
     * @param int $h
50
     * @return string
51
     */
52
    public static function everyWeek($day = 1, $h = 3)
53
    {
54
        return "0 $h * * $day";
55
    }
56
}
57