CreateFromInstanceCreator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 36
ccs 6
cts 6
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A construct() 0 3 1
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
7
declare(strict_types=1);
8
9
namespace Tebru\Gson\Internal\ObjectConstructor;
10
11
use Tebru\Gson\InstanceCreator;
12
use Tebru\Gson\Internal\ObjectConstructor;
13
use Tebru\PhpType\TypeToken;
14
15
/**
16
 * Class CreateFromInstanceCreator
17
 *
18
 * Instantiate a class using a custom [@see InstanceCreator]
19
 *
20
 * @author Nate Brunette <[email protected]>
21
 */
22
final class CreateFromInstanceCreator implements ObjectConstructor
23
{
24
    /**
25
     * User class that instantiates a class in a custom way
26
     *
27
     * @var InstanceCreator
28
     */
29
    private $instanceCreator;
30
31
    /**
32
     * Php Type instance
33
     *
34
     * @var TypeToken
35
     */
36
    private $type;
37
38
    /**
39
     * Constructor
40
     *
41
     * @param InstanceCreator $instanceCreator
42
     * @param TypeToken $type
43
     */
44 1
    public function __construct(InstanceCreator $instanceCreator, TypeToken $type)
45
    {
46 1
        $this->instanceCreator = $instanceCreator;
47 1
        $this->type = $type;
48 1
    }
49
50
    /**
51
     * Returns the instantiated object
52
     *
53
     * @return object
54
     */
55 1
    public function construct()
56
    {
57 1
        return $this->instanceCreator->createInstance($this->type);
58
    }
59
}
60