GetAllRetailsResult   A
last analyzed

Complexity

Total Complexity 19

Size/Duplication

Total Lines 142
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
wmc 19
lcom 2
cbo 1
dl 142
loc 142
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
B getSchema() 13 13 7
A setSchema() 6 6 1
B getAny() 13 13 7
A setAny() 6 6 1
A __set_state() 4 4 1
A __toString() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/*
4
 * This file is part of Smsa WebService package.
5
 * (c) Hamoud Alhoqbani <[email protected]>
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Alhoqbani\SmsaWebService\Soap\Type;
11
12
use \WsdlToPhp\PackageBase\AbstractStructBase;
13
14
/**
15
 * This class stands for getAllRetailsResult Type
16
 *
17
 * @date 2018/04/06
18
 * @codeVersion 0.0.1
19
 */
20 View Code Duplication
class GetAllRetailsResult extends AbstractStructBase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    /**
23
     * The schema
24
     * Meta informations extracted from the WSDL
25
     * - ref: s:schema
26
     *
27
     * @var \DOMDocument
28
     */
29
    public $schema;
30
    /**
31
     * The any
32
     *
33
     * @var \DOMDocument
34
     */
35
    public $any;
36
37
    /**
38
     * Constructor method for getAllRetailsResult
39
     *
40
     * @uses GetAllRetailsResult::setSchema()
41
     * @uses GetAllRetailsResult::setAny()
42
     *
43
     * @param \DOMDocument $schema
44
     * @param \DOMDocument $any
45
     */
46
    public function __construct(\DOMDocument $schema = null, \DOMDocument $any = null)
47
    {
48
        $this
49
            ->setSchema($schema)
50
            ->setAny($any);
51
    }
52
53
    /**
54
     * Get schema value
55
     *
56
     * @uses \DOMDocument::loadXML()
57
     * @uses \DOMDocument::hasChildNodes()
58
     * @uses \DOMDocument::saveXML()
59
     * @uses \DOMNode::item()
60
     * @uses \Alhoqbani\SmsaWebService\Soap\Type\GetAllRetailsResult::setSchema()
61
     *
62
     * @param bool $asString true: returns XML string, false: returns \DOMDocument
63
     *
64
     * @return \DOMDocument|null
65
     */
66
    public function getSchema($asString = true)
67
    {
68
        if (!empty($this->schema) && !($this->schema instanceof \DOMDocument)) {
69
            $dom = new \DOMDocument('1.0', 'UTF-8');
70
            $dom->formatOutput = true;
71
            if ($dom->loadXML($this->schema)) {
72
                $this->setSchema($dom);
73
            }
74
            unset($dom);
75
        }
76
77
        return ($asString && ($this->schema instanceof \DOMDocument) && $this->schema->hasChildNodes()) ? $this->schema->saveXML($this->schema->childNodes->item(0)) : $this->schema;
78
    }
79
80
    /**
81
     * Set schema value
82
     *
83
     * @param \DOMDocument $schema
84
     *
85
     * @return \Alhoqbani\SmsaWebService\Soap\Type\GetAllRetailsResult
86
     */
87
    public function setSchema(\DOMDocument $schema = null)
88
    {
89
        $this->schema = $schema;
90
91
        return $this;
92
    }
93
94
    /**
95
     * Get any value
96
     *
97
     * @uses \DOMDocument::loadXML()
98
     * @uses \DOMDocument::hasChildNodes()
99
     * @uses \DOMDocument::saveXML()
100
     * @uses \DOMNode::item()
101
     * @uses \Alhoqbani\SmsaWebService\Soap\Type\GetAllRetailsResult::setAny()
102
     *
103
     * @param bool $asString true: returns XML string, false: returns \DOMDocument
104
     *
105
     * @return \DOMDocument|null
106
     */
107
    public function getAny($asString = true)
108
    {
109
        if (!empty($this->any) && !($this->any instanceof \DOMDocument)) {
110
            $dom = new \DOMDocument('1.0', 'UTF-8');
111
            $dom->formatOutput = true;
112
            if ($dom->loadXML($this->any)) {
113
                $this->setAny($dom);
114
            }
115
            unset($dom);
116
        }
117
118
        return ($asString && ($this->any instanceof \DOMDocument) && $this->any->hasChildNodes()) ? $this->any->saveXML($this->any->childNodes->item(0)) : $this->any;
119
    }
120
121
    /**
122
     * Set any value
123
     *
124
     * @param \DOMDocument $any
125
     *
126
     * @return \Alhoqbani\SmsaWebService\Soap\Type\GetAllRetailsResult
127
     */
128
    public function setAny(\DOMDocument $any = null)
129
    {
130
        $this->any = $any;
131
132
        return $this;
133
    }
134
135
    /**
136
     * Method called when an object has been exported with var_export() functions
137
     * It allows to return an object instantiated with the values
138
     *
139
     * @see AbstractStructBase::__set_state()
140
     *
141
     * @uses AbstractStructBase::__set_state()
142
     *
143
     * @param array $array the exported values
144
     *
145
     * @return \Alhoqbani\SmsaWebService\Soap\Type\GetAllRetailsResult
146
     */
147
    public static function __set_state(array $array)
148
    {
149
        return parent::__set_state($array);
150
    }
151
152
    /**
153
     * Method returning the class name
154
     *
155
     * @return string __CLASS__
156
     */
157
    public function __toString()
158
    {
159
        return __CLASS__;
160
    }
161
}
162