FunctionDescriptor   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 94.74%

Importance

Changes 0
Metric Value
dl 0
loc 61
ccs 18
cts 19
cp 0.9474
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 3

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setArguments() 0 4 1
A getArguments() 0 4 1
A getResponse() 0 15 3
A setReturnType() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of phpDocumentor.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author    Mike van Riel <[email protected]>
11
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
12
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
13
 * @link      http://phpdoc.org
14
 */
15
16
namespace phpDocumentor\Descriptor;
17
18
use phpDocumentor\Descriptor\Tag\ReturnDescriptor;
19
use phpDocumentor\Reflection\Type;
20
21
/**
22
 * Descriptor representing a function.
23
 */
24
class FunctionDescriptor extends DescriptorAbstract implements Interfaces\FunctionInterface
25
{
26
    /** @var Collection $arguments */
27
    protected $arguments;
28
29
    /** @var Type */
30
    private $returnType;
31
32
    /**
33
     * Initializes the all properties representing a collection with a new Collection object.
34
     */
35 1
    public function __construct()
36
    {
37 1
        parent::__construct();
38
39 1
        $this->setArguments(new Collection());
40 1
    }
41
42
    /**
43
     * {@inheritDoc}
44
     */
45 1
    public function setArguments(Collection $arguments)
46
    {
47 1
        $this->arguments = $arguments;
48 1
    }
49
50
    /**
51
     * {@inheritDoc}
52
     */
53 1
    public function getArguments()
54
    {
55 1
        return $this->arguments;
56
    }
57
58
    /**
59
     * {@inheritDoc}
60
     */
61 1
    public function getResponse(): ReturnDescriptor
62
    {
63 1
        $definedReturn = new ReturnDescriptor('return');
64 1
        $definedReturn->setType($this->returnType);
65
66
        /** @var Collection|null $returnTags */
67 1
        $returnTags = $this->getTags()->get('return');
68
69 1
        if ($returnTags instanceof Collection && $returnTags->count() > 0) {
70
            /** @var ReturnDescriptor $returnTag */
71
            return current($returnTags->getAll());
72
        }
73
74 1
        return $definedReturn;
75
    }
76
77
    /**
78
     * Sets return type of this method.
79
     */
80 1
    public function setReturnType(Type $returnType)
81
    {
82 1
        $this->returnType = $returnType;
83 1
    }
84
}
85