DateTime::getUriParameterValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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