Completed
Push — master ( 2b4960...a6770b )
by Peter
04:05
created

Util   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 38
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMondayThisWeek() 0 10 2
A roundDate() 0 4 1
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2016, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace GpsLab\Bundle\DateBundle;
11
12
class Util
13
{
14
    /**
15
     * Bugfix for get monday of this week.
16
     *
17
     * @see https://bugs.php.net/bug.php?id=63740
18
     *
19
     * @param \DateTime $date
20
     *
21
     * @return \DateTime
22
     */
23 9
    public static function getMondayThisWeek(\DateTime $date)
24
    {
25 9
        $monday = clone $date;
26 9
        $number = $monday->format('N');
27 9
        if ($number != 1) {
28 8
            $monday->modify('-'.($number - 1).' day');
29 8
        }
30
31 9
        return $monday;
32
    }
33
34
    /**
35
     * @deprecated it will be removed in later.
36
     *
37
     * @see RoundDate::round()
38
     * @codeCoverageIgnore
39
     *
40
     * @param \DateTime $date
41
     * @param int $seconds
42
     *
43
     * @return \DateTime
44
     */
45
    public static function roundDate(\DateTime $date, $seconds)
46
    {
47
        return RoundDate::round($date, $seconds);
48
    }
49
}
50