Util   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
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 37
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
     * @see RoundDate::round()
37
     * @codeCoverageIgnore
38
     *
39
     * @param \DateTime $date
40
     * @param int $seconds
41
     *
42
     * @return \DateTime
43
     */
44
    public static function roundDate(\DateTime $date, $seconds)
45
    {
46
        return RoundDate::round($date, $seconds);
47
    }
48
}
49