OwnerFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 31
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 8 2
1
<?php
2
declare(strict_types = 1);
3
/**
4
 *
5
 * Copyright (C) 2018  Ross Mitchell
6
 *
7
 * This file is part of RossMitchell/UpdateCloudFlare.
8
 *
9
 * RossMitchell/UpdateCloudFlare is free software: you can redistribute
10
 * it and/or modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
namespace RossMitchell\UpdateCloudFlare\Factories\Responses\Results;
24
25
use RossMitchell\UpdateCloudFlare\Helpers\Hydrator;
26
use RossMitchell\UpdateCloudFlare\Responses\Results\Owner;
27
use Symfony\Component\Console\Exception\LogicException;
28
29
/**
30
 * Class OwnerFactory
31
 * @package RossMitchell\UpdateCloudFlare\Factories\Responses\Results
32
 */
33
class OwnerFactory
34
{
35
    /**
36
     * @var Hydrator
37
     */
38
    private $hydrator;
39
40
    /**
41
     * OwnerFactory constructor.
42
     *
43
     * @param Hydrator $hydrator
44
     */
45 56
    public function __construct(Hydrator $hydrator)
46
    {
47 56
        $this->hydrator = $hydrator;
48 56
    }
49
50
    /**
51
     * @param \stdClass $data
52
     *
53
     * @return Owner
54
     * @throws LogicException
55
     */
56 33
    public function create(\stdClass $data): Owner
57
    {
58 33
        $owner = new Owner();
59 33
        foreach (['id', 'email', 'owner_type'] as $property) {
60 33
            $this->hydrator->setProperty($owner, $data, $property);
61
        }
62
63 30
        return $owner;
64
    }
65
66
}
67