TypeOf   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 25
ccs 9
cts 9
cp 1
rs 10
c 2
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toString() 0 7 3
A __construct() 0 4 1
1
<?php
2
3
namespace Swaggest\PhpCodeBuilder\Types;
4
5
use Swaggest\PhpCodeBuilder\PhpAnyType;
6
use Swaggest\PhpCodeBuilder\PhpClassTraitInterface;
7
use Swaggest\PhpCodeBuilder\PhpTemplate;
8
9
class TypeOf extends PhpTemplate
10
{
11
    /** @var PhpAnyType */
12
    private $type;
13
14
    /** @var bool */
15
    private $renderPhpDoc;
16
17
    /**
18
     * TypeOf constructor.
19
     * @param PhpAnyType $type
20
     */
21 10
    public function __construct(PhpAnyType $type, $renderPhpDoc = false)
22
    {
23 10
        $this->renderPhpDoc = $renderPhpDoc;
24 10
        $this->type = $type;
25 10
    }
26
27 10
    protected function toString()
28
    {
29 10
        if ($this->type instanceof PhpClassTraitInterface) {
30 10
            return $this->type->getReference();
31
        } else {
32 7
            $res = $this->renderPhpDoc ? $this->type->renderPhpDocType() : $this->type->renderArgumentType();
33 7
            return $res;
34
        }
35
    }
36
37
38
}