Completed
Push — master ( 28517b...4142e2 )
by Mike
13s queued 11s
created

ClassString::__toString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of phpDocumentor.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @link      http://phpdoc.org
12
 */
13
14
namespace phpDocumentor\Reflection\Types;
15
16
use phpDocumentor\Reflection\Fqsen;
17
use phpDocumentor\Reflection\Type;
18
19
/**
20
 * Value Object representing the type 'string'.
21
 */
22
final class ClassString implements Type
23
{
24
    /** @var Fqsen|null */
25
    private $fqsen;
26
27
    /**
28
     * Initializes this representation of a class string with the given Fqsen.
29
     */
30
    public function __construct(?Fqsen $fqsen = null)
31
    {
32
        $this->fqsen = $fqsen;
33
    }
34
35
    /**
36
     * Returns the FQSEN associated with this object.
37
     */
38
    public function getFqsen() : ?Fqsen
39
    {
40
        return $this->fqsen;
41
    }
42
43
    /**
44
     * Returns a rendered output of the Type as it would be used in a DocBlock.
45
     */
46
    public function __toString() : string
47
    {
48
        if ($this->fqsen === null) {
49
            return 'class-string';
50
        } else {
51
            return 'class-string<' . (string)$this->fqsen . '>';
52
        }
53
    }
54
}
55