Completed
Push — master ( 9cf5c1...719e81 )
by Jaap
01:46
created

Nullable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 37
ccs 5
cts 7
cp 0.7143
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getActualType() 0 4 1
A __toString() 0 4 1
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @copyright 2010-2017 Mike van Riel<[email protected]>
9
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 * @link      http://phpdoc.org
11
 */
12
13
namespace phpDocumentor\Reflection\Types;
14
15
use phpDocumentor\Reflection\Type;
16
17
/**
18
 * Value Object representing a nullable type. The real type is wrapped.
19
 */
20
final class Nullable implements Type
21
{
22
    /**
23
     * @var Type
24
     */
25
    private $realType;
26
27
    /**
28
     * Initialises this nullable type using the real type embedded
29
     *
30
     * @param Type $realType
31
     */
32 1
    public function __construct(Type $realType)
33
    {
34 1
        $this->realType = $realType;
35 1
    }
36
37
    /**
38
     * Provide access to the actual type directly, if needed.
39
     *
40
     * @return Type
41
     */
42 1
    public function getActualType()
43
    {
44 1
        return $this->realType;
45
    }
46
47
    /**
48
     * Returns a rendered output of the Type as it would be used in a DocBlock.
49
     *
50
     * @return string
51
     */
52
    public function __toString()
53
    {
54
        return '?' . $this->realType->__toString();
55
    }
56
}
57