ArrayOf::renderArgumentType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
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
}