Completed
Push — master ( 499778...79f24a )
by Emily
9s
created

CollectionType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A equals() 0 6 2
A __toString() 0 4 1
1
<?php
2
/**
3
 * This file is part of the Composite Utils package.
4
 *
5
 * (c) Emily Shepherd <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the
8
 * LICENSE.md file that was distributed with this source code.
9
 *
10
 * @package spaark/composite-utils
11
 * @author Emily Shepherd <[email protected]>
12
 * @license MIT
13
 */
14
15
namespace Spaark\CompositeUtils\Model\Reflection\Type;
16
17
/**
18
 * Represents a data type which is a collection of items
19
 *
20
 * @property-read AbstractType $of
21
 */
22
class CollectionType extends AbstractType
23
{
24
    /**
25
     * What is this a collection of
26
     *
27
     * @readable
28
     * @var AbstractType
29
     */
30
    protected $of;
31
32
    /**
33
     * Creates the CollectionType of the given subtype
34
     *
35
     * @param AbstractType $of The data type that this is a collection
36
     *     of
37
     */
38 13
    public function __construct(AbstractType $of)
39
    {
40 13
        $this->of = $of;
41 13
    }
42
43
    /**
44
     * {@inheritDoc}
45
     */
46
    public function equals($object) : bool
47
    {
48
        return
49
            $type instanceof CollectionType &&
0 ignored issues
show
Bug introduced by
The variable $type does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
50
            $this->of->equals($type->of);
51
    }
52
53
    public function __toString() : string
54
    {
55
        return $this->of->__toString() . '[]';
56
    }
57
}
58