EventFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 17
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromData() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\NestApi\Client\Factory\Device\Camera;
6
7
use DateTimeImmutable;
8
use LauLamanApps\NestApi\Client\__shared\AbstractFactory;
9
use LauLamanApps\NestApi\Client\Device\Camera\Event;
10
11
final class EventFactory extends AbstractFactory implements EventFactoryInterface
12
{
13 2
    public function fromData(?array $data): ?Event
14
    {
15 2
        if (!$data) {
16 1
            return null;
17
        }
18
19 1
        return new Event(
20 1
            $this->extractDateTimeImmutableOrNull('start_time', $data),
21 1
            $this->extractDateTimeImmutableOrNull('end_time', $data),
22 1
            $this->extractDateTimeImmutableOrNull('urls_expire_time', $data),
23 1
            $this->extractBoolean('has_sound', $data),
24 1
            $this->extractBoolean('has_motion', $data),
25 1
            $this->extractBoolean('has_person', $data),
26 1
            $this->extractString('web_url', $data),
27 1
            $this->extractString('app_url', $data)
28
        );
29
    }
30
}
31