Completed
Push — master ( 0675d2...e555ac )
by Jaap
01:36
created

Collection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 43
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getFqsen() 0 4 1
A __toString() 0 8 2
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-2015 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
use phpDocumentor\Reflection\Fqsen;
17
18
/**
19
 * Represents a collection type as described in the PSR-5, the PHPDoc Standard.
20
 *
21
 * A collection can be represented in two forms:
22
 *
23
 * 1. `ACollectionObject<aValueType>`
24
 * 2. `ACollectionObject<aValueType,aKeyType>`
25
 *
26
 * - ACollectionObject can be 'array' or an object that can act as an array
27
 * - aValueType and aKeyType can be any type expression
28
 */
29
final class Collection extends AbstractList
30
{
31
32
    /** @var Fqsen */
33
    private $fqsen;
34
35
    /**
36
     * Initializes this representation of an array with the given Type or Fqsen.
37
     *
38
     * @param Type $valueType
39
     * @param Type $keyType
40
     */
41
    public function __construct(Fqsen $fqsen, Type $valueType, Type $keyType = null)
42
    {
43
        parent::__construct($valueType, $keyType);
44
45
        $this->fqsen = $fqsen;
46
    }
47
48
    /**
49
     * Returns the FQSEN associated with this object.
50
     *
51
     * @return Fqsen
52
     */
53
    public function getFqsen()
54
    {
55
        return $this->fqsen;
56
    }
57
58
    /**
59
     * Returns a rendered output of the Type as it would be used in a DocBlock.
60
     *
61
     * @return string
62
     */
63
    public function __toString()
64
    {
65
        if ($this->keyType === null) {
66
            return $this->fqsen.'<'.$this->valueType . '>';
67
        }
68
69
        return $this->fqsen.'<'.$this->keyType . ',' . $this->valueType . '>';
70
    }
71
}
72