Completed
Push — master ( 17312a...d17d72 )
by Mario
03:12
created

GetTimeEntriesStartedInDateRange   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 76.92%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 46
ccs 10
cts 13
cp 0.7692
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A constructUrl() 0 14 3
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
    public $uri = 'time_entries';
20
21
    /**
22
     * @var \DateTime
23
     */
24
    public $startDate;
25
26
    /**
27
     * @var \DateTime
28
     */
29
    public $endDate;
30
31
    /**
32
     * GetTimeEntriesInDateRange constructor.
33
     *
34
     * @param array $properties
35
     */
36 5
    public function __construct(array $properties)
37
    {
38 5
        parent::__construct($properties);
39 5
        $this->constructUrl();
40 5
    }
41
42
    /**
43
     * Constructs query part of URL
44
     */
45 5
    protected function constructUrl()
46
    {
47 5
        if (!$this->startDate instanceof \DateTime) {
48
            return;
49
        }
50
51 5
        if (!$this->endDate instanceof \DateTime) {
52
            $this->endDate = new \DateTime();
53
        }
54
55 5
        $queryString = '?start_date=' . $this->startDate->format('c') . '&end_date=' . $this->endDate->format('c');
56
57 5
        $this->uri = urlencode($this->uri . $queryString);
58 5
    }
59
}
60