ArrayOf   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 41
ccs 9
cts 11
cp 0.8182
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A renderPhpDocType() 0 8 3
A getType() 0 3 1
A __construct() 0 3 1
A renderArgumentType() 0 3 1
1
<?php
2
3
namespace Swaggest\PhpCodeBuilder\Types;
4
5
6
use Swaggest\PhpCodeBuilder\PhpAnyType;
7
use Swaggest\PhpCodeBuilder\PhpStdType;
8
9
class ArrayOf implements PhpAnyType
10
{
11
    /** @var PhpAnyType */
12
    private $type;
13
14
    /**
15
     * @return PhpAnyType
16
     */
17
    public function getType()
18
    {
19
        return $this->type;
20
    }
21
22
    /**
23
     * ArrayOf constructor.
24
     * @param PhpAnyType $type
25 4
     */
26
    public function __construct(PhpAnyType $type)
27 4
    {
28 4
        $this->type = $type;
29
    }
30
31
    /**
32
     * @return string
33 2
     */
34
    public function renderArgumentType()
35 2
    {
36
        return '';
37
    }
38
39
    /**
40
     * @return string
41 4
     */
42
    public function renderPhpDocType()
43 4
    {
44 3
        if ($this->type instanceof OrType) {
45
            return $this->type->renderArrayPhpDocType();
46 4
        } elseif ($this->type === PhpStdType::mixed()) {
47
            return 'array';
48
        } else {
49
            return $this->type->renderPhpDocType() . '[]';
50
        }
51
    }
52
53
54
}