week_ending_seconds()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
if (!function_exists('week_ending_seconds')) {
4
    /**
5
     * Calculate time to end of the week in seconds
6
     *
7
     * @param int $weeks
8
     * @return int
9
     */
10
    function week_ending_seconds(int $weeks = 0): int
11
    {
12
        $weeks = max($weeks, 0);
13
14
        $now = now();
15
        $end = $now->clone()->addWeeks($weeks);
16
        $end = $end->endOfWeek(config('laracache.last-day-of-week'));
17
18
        return $end->endOfDay()->diffInSeconds($now, true);
19
    }
20
}
21
22
if (!function_exists('day_ending_seconds')) {
23
    /**
24
     * Calculate time to end of the day in seconds
25
     *
26
     * @param int $days
27
     * @return int
28
     */
29
    function day_ending_seconds(int $days = 0): int
30
    {
31
        $days = max($days, 0);
32
33
        $now = now();
34
        $end = $now->clone()->addDays($days);
35
36
        return $end->endOfDay()->diffInSeconds($now, true);
37
    }
38
}
39