GetTimeEntriesStartedInDateRange::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Marek\Toggable\API\Http\Request\TimeEntry;
4
5
use Marek\Toggable\API\Http\Request\Request;
6
7
/**
8
 * Class GetTimeEntriesStartedInDateRange
9
 * @package Marek\Toggable\API\Http\Request\TimeEntry
10
 *
11
 * @property-read \DateTime $startDate
12
 * @property-read \DateTime $endDate
13
 */
14
class GetTimeEntriesStartedInDateRange extends Request
15
{
16
    /**
17
     * @var string
18
     */
19
    protected $uri = 'time_entries';
20
21
    /**
22
     * @var \DateTime
23
     */
24
    protected $startDate;
25
26
    /**
27
     * @var \DateTime
28
     */
29
    protected $endDate;
30
31
    /**
32
     * GetTimeEntriesInDateRange constructor.
33
     *
34
     * @param array $properties
35
     */
36 8
    public function __construct(array $properties)
37
    {
38 8
        parent::__construct($properties);
39 8
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44 3
    public function getUri()
45
    {
46 3
        if (!$this->startDate instanceof \DateTime) {
47 1
            return $this->uri;
48
        }
49
50 2
        if (!$this->endDate instanceof \DateTime) {
51 1
            $this->endDate = new \DateTime();
52 1
        }
53
54 2
        $queryString = '?start_date=' . $this->startDate->format('c') . '&end_date=' . $this->endDate->format('c');
55
56 2
        return urlencode($this->uri . $queryString);
57
    }
58
}
59