Completed
Push — master ( 2fbe7d...a80544 )
by Piotr
03:44
created

Node   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 2
Metric Value
wmc 9
c 5
b 0
f 2
lcom 2
cbo 1
dl 0
loc 97
ccs 22
cts 22
cp 1
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getElements() 0 4 1
A getType() 0 4 1
A getName() 0 4 1
A getNameForArray() 0 4 1
A getNameForObject() 0 4 1
A getSanitizedName() 0 4 1
A isArray() 0 4 1
A isObject() 0 4 1
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\Parser;
25
use Ouzo\Utilities\Inflector;
26
27
/**
28
 * Node
29
 *
30
 * @author Piotr Olaszewski <[email protected]>
31
 */
32
class Node
33
{
34
    /**
35
     * @var string
36
     */
37
    private $type;
38
    /**
39
     * @var string
40
     */
41
    private $name;
42
    /**
43
     * @var bool
44
     */
45
    private $isArray;
46
    /**
47
     * @var Node[]
48
     */
49
    private $elements;
50
51
    /**
52
     * @param string $type
53
     * @param string $name
54
     * @param boolean $isArray
55
     * @param Node[] $elements
56
     */
57 20
    public function __construct($type, $name, $isArray, array $elements = array())
58
    {
59 20
        $this->type = $type;
60 20
        $this->name = $name;
61 20
        $this->isArray = (bool)$isArray;
62 20
        $this->elements = $elements;
63 20
    }
64
65
    /**
66
     * @return string
67
     */
68 2
    public function getType()
69
    {
70 2
        return $this->type;
71
    }
72
73
    /**
74
     * @return string
75
     */
76 1
    public function getName()
77
    {
78 1
        return $this->name;
79
    }
80
81
    /**
82
     * @return string
83
     */
84 1
    public function getNameForArray()
85
    {
86 1
        return 'ArrayOf' . ucfirst($this->getSanitizedName());
87
    }
88
89
    /**
90
     * @return string
91
     */
92 2
    public function getNameForObject()
93
    {
94 2
        return Inflector::singularize(ucfirst($this->getSanitizedName()));
95
    }
96
97
    /**
98
     * @return string
99
     */
100 4
    public function getSanitizedName()
101
    {
102 4
        return str_replace('$', '', $this->name);
103
    }
104
105
    /**
106
     * @return boolean
107
     */
108 2
    public function isArray()
109
    {
110 2
        return $this->isArray;
111
    }
112
113
    /**
114
     * @return boolean
115
     */
116 2
    public function isObject()
117
    {
118 2
        return $this->type == Parser::OBJECT_TYPE;
119
    }
120
121
    /**
122
     * @return Node[]
123
     */
124 5
    public function getElements()
125
    {
126 5
        return $this->elements;
127
    }
128
}
129