DateTime   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getDateTime() 0 4 1
A __construct() 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 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