Completed
Push — master ( 6551be...435af8 )
by Mario
09:41
created

DateTime   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getDateTime() 0 4 1
A getGetParameterValue() 0 4 1
A getGetParameterName() 0 4 1
A getUriParameterValue() 0 4 1
A getUriParameterName() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Marek\OpenWeatherMap\API\Value\Parameter\Input;
6
7
use Marek\OpenWeatherMap\API\Value\Parameter\GetParameterInterface;
8
use Marek\OpenWeatherMap\API\Value\Parameter\UriParameterInterface;
9
10
class DateTime implements GetParameterInterface, UriParameterInterface
11
{
12
    /**
13
     * @var \DateTimeInterface
14
     */
15
    protected $datetime;
16
17
    /**
18
     * Datetime constructor.
19
     *
20
     * @param \DateTimeInterface $datetime
21
     */
22
    public function __construct(\DateTimeInterface $datetime)
23
    {
24
        $this->datetime = $datetime;
25
    }
26
27
    /**
28
     * @return string
29
     */
30
    public function getDateTime()
31
    {
32
        return $this->datetime;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getGetParameterValue()
39
    {
40
        return $this->datetime->getTimestamp();
41
    }
42
43
    public function getGetParameterName()
44
    {
45
        throw new \RuntimeException('Not implemented.');
46
    }
47
48
    public function getUriParameterValue()
49
    {
50
        return $this->datetime->format('Y-m-d\TH:i:s\Z');
51
    }
52
53
    public function getUriParameterName()
54
    {
55
        return 'datetime';
56
    }
57
58
59
}
60