Completed
Push — master ( 01652b...58468d )
by Piotr
07:39
created

Method::getReturn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Copyright (C) 2013-2016
4
 * Piotr Olaszewski <[email protected]>
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 * SOFTWARE.
23
 */
24
namespace WSDL\Builder;
25
26
use Ouzo\Utilities\Arrays;
27
use Ouzo\Utilities\Functions;
28
use WSDL\Parser\Node;
29
30
/**
31
 * Method
32
 *
33
 * @author Piotr Olaszewski <[email protected]>
34
 */
35
class Method
36
{
37
    /**
38
     * @var string
39
     */
40
    private $name;
41
    /**
42
     * @var Parameter[]
43
     */
44
    private $parameters;
45
    /**
46
     * @var Parameter
47
     */
48
    private $return;
49
50
    /**
51
     * @param string $name
52
     * @param Parameter[] $parameters
53
     * @param Parameter $return
54
     */
55
    public function __construct($name, array $parameters, Parameter $return)
56
    {
57
        $this->name = $name;
58
        $this->parameters = $parameters;
59
        $this->return = $return;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function getName()
66
    {
67
        return $this->name;
68
    }
69
70
    /**
71
     * @return Parameter[]
72
     */
73
    public function getParameters()
74
    {
75
        return $this->parameters;
76
    }
77
78
    /**
79
     * @return Parameter|null
80
     */
81
    public function getHeaderParameter()
82
    {
83
        return Arrays::find($this->parameters, function (Parameter $parameter) {
84
            return $parameter->isHeader();
85
        });
86
    }
87
88
    /**
89
     * @return Parameter[]|array
90
     */
91
    public function getNoHeaderParameters()
92
    {
93
        return Arrays::filter($this->parameters, function (Parameter $parameter) {
94
            return !$parameter->isHeader();
95
        });
96
    }
97
98
    /**
99
     * @return Node[]
100
     */
101
    public function getNoHeaderParametersNodes()
102
    {
103
        return Arrays::map($this->getNoHeaderParameters(), Functions::extractExpression('getNode()'));
104
    }
105
106
    /**
107
     * @return Parameter
108
     */
109
    public function getReturn()
110
    {
111
        return $this->return;
112
    }
113
114
    /**
115
     * @return Parameter|null
116
     */
117
    public function getHeaderReturn()
118
    {
119
        if ($this->return->isHeader()) {
120
            return $this->return;
121
        }
122
        return null;
123
    }
124
125
    /**
126
     * @return Node
127
     */
128
    public function getReturnNode()
129
    {
130
        return $this->return->getNode();
131
    }
132
}
133