FunctionLike   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1
Metric Value
wmc 5
lcom 2
cbo 1
dl 0
loc 50
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A makeReturnByRef() 0 5 1
A addParam() 0 11 2
A addParams() 0 7 2
1
<?php
2
3
namespace PhpParser\Builder;
4
5
use PhpParser;
6
use PhpParser\Node;
7
use PhpParser\Node\Stmt;
8
9
abstract class FunctionLike extends Declaration
10
{
11
    protected $returnByRef = false;
12
    protected $params = array();
13
14
    /**
15
     * Make the function return by reference.
16
     *
17
     * @return $this The builder instance (for fluid interface)
18
     */
19
    public function makeReturnByRef() {
20
        $this->returnByRef = true;
21
22
        return $this;
23
    }
24
25
    /**
26
     * Adds a parameter.
27
     *
28
     * @param Node\Param|Param $param The parameter to add
29
     *
30
     * @return $this The builder instance (for fluid interface)
31
     */
32
    public function addParam($param) {
33
        $param = $this->normalizeNode($param);
34
35
        if (!$param instanceof Node\Param) {
36
            throw new \LogicException(sprintf('Expected parameter node, got "%s"', $param->getType()));
37
        }
38
39
        $this->params[] = $param;
40
41
        return $this;
42
    }
43
44
    /**
45
     * Adds multiple parameters.
46
     *
47
     * @param array $params The parameters to add
48
     *
49
     * @return $this The builder instance (for fluid interface)
50
     */
51
    public function addParams(array $params) {
52
        foreach ($params as $param) {
53
            $this->addParam($param);
54
        }
55
56
        return $this;
57
    }
58
}