ParameterCommentGenerator   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 49
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A docBlock() 0 14 3
A getVarNameProposal() 0 4 1
A documentPrimitive() 0 4 1
A documentClass() 0 4 1
A documentInterfaces() 0 4 1
1
<?php
2
3
/*
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
namespace DicDoc;
10
11
12
/**
13
 * Class ParameterCommentGenerator
14
 *
15
 * @package DicDoc
16
 */
17
class ParameterCommentGenerator implements Interfaces\ParameterDocumentator
18
{
19
    /**
20
     * @var ParameterInformation
21
     */
22
    private $parameter;
23
24
25
    /**
26
     * @param ParameterInformation $parameter
27
     *
28
     * @return string
29
     */
30
    public function docBlock(ParameterInformation $parameter)
31
    {
32
        $this->parameter = $parameter;
33
34
        if (!$parameter->isObject()) {
35
            return $this->documentPrimitive();
36
        }
37
38
        if (empty($parameter->getImplements())) {
39
            return $this->documentClass();
40
        }
41
42
        return $this->documentInterfaces();
43
    }
44
45
    private function getVarNameProposal()
46
    {
47
        return lcfirst($this->parameter->getShortClassName());
48
    }
49
50
    private function documentPrimitive()
51
    {
52
        return "/** @var ".$this->parameter->getType()." */";
53
    }
54
55
    private function documentClass()
56
    {
57
        return "/** @var \\".$this->parameter->getClassName()." \$".$this->getVarNameProposal()." */";
58
    }
59
60
    private function documentInterfaces()
61
    {
62
        return "/** @var \\".implode("|\\", $this->parameter->getImplements())." \$".$this->getVarNameProposal()." */";
63
    }
64
65
}
66