EventFactory::fromData()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 1
dl 0
loc 15
ccs 12
cts 12
cp 1
crap 2
rs 9.9
c 0
b 0
f 0
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