User   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A hydrate() 0 10 1
A supports() 0 4 1
1
<?php
2
3
namespace Shrikeh\PagerDuty\Hydrator;
4
5
use stdClass;
6
use Shrikeh\PagerDuty\Collection\ContactMethods;
7
use Shrikeh\PagerDuty\Hydrator;
8
use Shrikeh\PagerDuty\Hydrator\ContactMethod as ContactMethodHydrator;
9
use Shrikeh\PagerDuty\Hydrator\Uri as UriHydrator;
10
use Shrikeh\PagerDuty\Entity\User\User as UserEntity;
11
12
final class User implements Hydrator
13
{
14
    private $contactMethodsHydrator;
15
    private $uriHydrator;
16
17
    public function __construct(
18
        ContactMethodHydrator $contactMethodsHydrator,
19
        UriHydrator $uriHydrator
20
    ) {
21
        $this->contactMethodsHydrator = $contactMethodsHydrator;
22
        $this->uriHydrator = $uriHydrator;
23
    }
24
25
    public function hydrate(stdClass $dto)
26
    {
27
        return UserEntity::fromData(
28
            ContactMethods::fromArray(array_map($this->contactMethodsHydrator, $dto->contact_methods)),
29
            $this->uriHydrator->hydrate($dto),
30
            $dto->name,
31
            $dto->email,
32
            $dto->summary
33
        );
34
    }
35
36
    public function supports($token)
37
    {
38
        return ('user' === $token);
39
    }
40
}
41