Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
7 / 7
CRAP
100.00% covered (success)
100.00%
1 / 1
DateTimeRange
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
7 / 7
8
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 startDateTime
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 endDateTime
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 startDate
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 endDate
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 startISO8601
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 endISO8601
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Fdsn\Webservices\Event\Structs;
3
4/**
5 * Data structure to handle DateTimw range
6 *
7 * @param \DateTime    $start    Start date time (from new DateTime() or date_create())
8 * @param \DateTime    $end    End date time (from  new DateTime() or date_create())
9 */
10class DateTimeRange {
11    const dateTimeFormat = 'Y-m-d\TH:i:s';
12    const dateFormat = 'Y-m-d';
13    const iso8601Format = 'c';
14
15    private \DateTime $start;
16    private \DateTime $end;
17
18    function __construct( \DateTime $start, \DateTime $end) {
19        if($start <= $end){
20            $this->start = $start;
21            $this->end = $end;
22        }
23        else{
24            $this->start = $end;
25            $this->end = $start;
26
27        }
28    }
29
30    /**
31     * Get start date time
32     * @return string     Start date time in format YYYY-mm-ddTHH:mm:ss'
33     */
34    public function startDateTime():string { return date_format($this->start, self::dateTimeFormat); }
35
36    /**
37     * Get end date time
38     * @return string     End date time in format YYYY-mm-ddTHH:mm:ss'
39     */
40    public function endDateTime():string { return date_format($this->end, self::dateTimeFormat); }
41
42
43    /**
44     * Get start date 
45     * @return string     Start date in format YYYY-mm-dd'
46     */
47    public function startDate():string { return date_format($this->start, self::dateFormat); }
48
49    /**
50     * Get end date 
51     * @return string     End date in format YYYY-mm-dd'
52     */
53    public function endDate():string { return date_format($this->end, self::dateFormat); }
54
55    /**
56     * Get start date time
57     * @return string     Start date time in format ISO 8601 (see: https://www.php.net/manual/it/datetime.format.php )
58     */
59    public function startISO8601():string { return date_format($this->start, self::iso8601Format); }
60
61    /**
62     * Get end date time
63     * @return string     End date time in format ISO 8601  (see: https://www.php.net/manual/it/datetime.format.php )
64     */
65    public function endISO8601():string { return date_format($this->end, self::iso8601Format); }
66
67} 

Branches

Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once. Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

DateTimeRange->__construct
18    function __construct( \DateTime $start, \DateTime $end) {
19        if($start <= $end){
19        if($start <= $end){
20            $this->start = $start;
24            $this->start = $end;
25            $this->end = $start;
26
27        }
28    }
28    }
DateTimeRange->endDate
53    public function endDate():string { return date_format($this->end, self::dateFormat); }
DateTimeRange->endDateTime
40    public function endDateTime():string { return date_format($this->end, self::dateTimeFormat); }
DateTimeRange->endISO8601
65    public function endISO8601():string { return date_format($this->end, self::iso8601Format); }
DateTimeRange->startDate
47    public function startDate():string { return date_format($this->start, self::dateFormat); }
DateTimeRange->startDateTime
34    public function startDateTime():string { return date_format($this->start, self::dateTimeFormat); }
DateTimeRange->startISO8601
59    public function startISO8601():string { return date_format($this->start, self::iso8601Format); }