ClassGenerator::handleValueMethod()   C
last analyzed

Complexity

Conditions 12
Paths 36

Size

Total Lines 64
Code Lines 45

Duplication

Lines 10
Ratio 15.63 %

Code Coverage

Tests 44
CRAP Score 12.2487

Importance

Changes 0
Metric Value
dl 10
loc 64
ccs 44
cts 50
cp 0.88
rs 6.0561
c 0
b 0
f 0
nc 36
cc 12
eloc 45
nop 4
crap 12.2487

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
namespace GoetasWebservices\Xsd\XsdToPhp\Php;
3
4
use Doctrine\Common\Inflector\Inflector;
5
use GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPClass;
6
use GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPClassOf;
7
use GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPProperty;
8
use Zend\Code\Generator;
9
use Zend\Code\Generator\DocBlock\Tag\ParamTag;
10
use Zend\Code\Generator\DocBlock\Tag\PropertyTag;
11
use Zend\Code\Generator\DocBlock\Tag\ReturnTag;
12
use Zend\Code\Generator\DocBlockGenerator;
13
use Zend\Code\Generator\MethodGenerator;
14
use Zend\Code\Generator\ParameterGenerator;
15
use Zend\Code\Generator\PropertyGenerator;
16
17
class ClassGenerator
18
{
19
20 8
    private function handleBody(Generator\ClassGenerator $class, PHPClass $type)
21
    {
22 8
        foreach ($type->getProperties() as $prop) {
23 7
            if ($prop->getName() !== '__value') {
24 7
                $this->handleProperty($class, $prop);
25 7
            }
26 8
        }
27 8
        foreach ($type->getProperties() as $prop) {
28 7
            if ($prop->getName() !== '__value') {
29 7
                $this->handleMethod($class, $prop, $type);
30 7
            }
31 8
        }
32
33 8
        if (count($type->getProperties()) === 1 && $type->hasProperty('__value')) {
34
            return false;
35
        }
36
37 8
        return true;
38
    }
39
40 View Code Duplication
    private function isNativeType(PHPClass $class)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
Duplication introduced by
This method 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...
41
    {
42
        return !$class->getNamespace() && in_array($class->getName(), [
43
            'string',
44
            'int',
45
            'float',
46
            'integer',
47
            'boolean',
48
            'array',
49
            'mixed',
50
            'callable'
51
        ]);
52
    }
53
54 2
    private function handleValueMethod(Generator\ClassGenerator $generator, PHPProperty $prop, PHPClass $class, $all = true)
0 ignored issues
show
Unused Code introduced by
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $all is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
55
    {
56 2
        $type = $prop->getType();
57
58 2
        $docblock = new DocBlockGenerator('Construct');
59 2
        $paramTag = new ParamTag("value", "mixed");
0 ignored issues
show
Documentation introduced by
'mixed' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
60 2
        $paramTag->setTypes(($type ? $type->getPhpType() : "mixed"));
61
62 2
        $docblock->setTag($paramTag);
63
64 2
        $param = new ParameterGenerator("value");
65 2
        if ($type && !$type->isNativeType()) {
66
            $param->setType($type->getPhpType());
67
        }
68 2
        $method = new MethodGenerator("__construct", [
69
            $param
70 2
        ]);
71 2
        $method->setDocBlock($docblock);
72 2
        $method->setBody("\$this->value(\$value);");
73
74 2
        $generator->addMethodFromGenerator($method);
75
76 2
        $docblock = new DocBlockGenerator('Gets or sets the inner value');
77 2
        $paramTag = new ParamTag("value", "mixed");
0 ignored issues
show
Documentation introduced by
'mixed' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
78 2 View Code Duplication
        if ($type && $type instanceof PHPClassOf) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
79
            $paramTag->setTypes($type->getArg()->getType()->getPhpType() . "[]");
80 2
        } elseif ($type) {
81 2
            $paramTag->setTypes($prop->getType()->getPhpType());
82 2
        }
83 2
        $docblock->setTag($paramTag);
84
85 2
        $returnTag = new ReturnTag("mixed");
0 ignored issues
show
Documentation introduced by
'mixed' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
86
87 2 View Code Duplication
        if ($type && $type instanceof PHPClassOf) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
88
            $returnTag->setTypes($type->getArg()->getType()->getPhpType() . "[]");
89 2
        } elseif ($type) {
90 2
            $returnTag->setTypes($type->getPhpType());
91 2
        }
92 2
        $docblock->setTag($returnTag);
93
94 2
        $param = new ParameterGenerator("value");
95 2
        $param->setDefaultValue(null);
96
97 2
        if ($type && !$type->isNativeType()) {
98
            $param->setType($type->getPhpType());
99
        }
100 2
        $method = new MethodGenerator("value", []);
101 2
        $method->setDocBlock($docblock);
102
103 2
        $methodBody = "if (\$args = func_get_args()) {" . PHP_EOL;
104 2
        $methodBody .= "    \$this->" . $prop->getName() . " = \$args[0];" . PHP_EOL;
105 2
        $methodBody .= "}" . PHP_EOL;
106 2
        $methodBody .= "return \$this->" . $prop->getName() . ";" . PHP_EOL;
107 2
        $method->setBody($methodBody);
108
109 2
        $generator->addMethodFromGenerator($method);
110
111 2
        $docblock = new DocBlockGenerator('Gets a string value');
112 2
        $docblock->setTag(new ReturnTag("string"));
0 ignored issues
show
Documentation introduced by
'string' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
113 2
        $method = new MethodGenerator("__toString");
114 2
        $method->setDocBlock($docblock);
115 2
        $method->setBody("return strval(\$this->" . $prop->getName() . ");");
116 2
        $generator->addMethodFromGenerator($method);
117 2
    }
118
119 7
    private function handleSetter(Generator\ClassGenerator $generator, PHPProperty $prop, PHPClass $class)
0 ignored issues
show
Unused Code introduced by
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
120
    {
121 7
        $methodBody = '';
122 7
        $docblock = new DocBlockGenerator();
123
124 7
        $docblock->setShortDescription("Sets a new " . $prop->getName());
125
126 7
        if ($prop->getDoc()) {
127
            $docblock->setLongDescription($prop->getDoc());
128
        }
129
130 7
        $patramTag = new ParamTag($prop->getName());
131 7
        $docblock->setTag($patramTag);
132
133 7
        $return = new ReturnTag("self");
0 ignored issues
show
Documentation introduced by
'self' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
134 7
        $docblock->setTag($return);
135
136 7
        $type = $prop->getType();
137
138 7
        $method = new MethodGenerator("set" . Inflector::classify($prop->getName()));
139
140 7
        $parameter = new ParameterGenerator($prop->getName(), "mixed");
141
142 7
        if ($type && $type instanceof PHPClassOf) {
143 4
            $patramTag->setTypes($type->getArg()
144 4
                    ->getType()->getPhpType() . "[]");
145 4
            $parameter->setType("array");
146
147 4
            if ($p = $type->getArg()->getType()->isSimpleType()
148 4
            ) {
149
                if (($t = $p->getType())) {
150
                    $patramTag->setTypes($t->getPhpType());
151
                }
152
            }
153 7
        } elseif ($type) {
154 3
            if ($type->isNativeType()) {
155 3
                $patramTag->setTypes($type->getPhpType());
156 3
            } elseif ($p = $type->isSimpleType()) {
157
                if (($t = $p->getType()) && !$t->isNativeType()) {
158
                    $patramTag->setTypes($t->getPhpType());
159
                    $parameter->setType($t->getPhpType());
160
                } elseif ($t && !$t->isNativeType()) {
161
                    $patramTag->setTypes($t->getPhpType());
162
                    $parameter->setType($t->getPhpType());
163
                } elseif ($t) {
164
                    $patramTag->setTypes($t->getPhpType());
165
                }
166
            } else {
167
                $patramTag->setTypes($type->getPhpType());
168
                $parameter->setType($type->getPhpType());
169
            }
170 3
        }
171
172 7
        $methodBody .= "\$this->" . $prop->getName() . " = \$" . $prop->getName() . ";" . PHP_EOL;
173 7
        $methodBody .= "return \$this;";
174 7
        $method->setBody($methodBody);
175 7
        $method->setDocBlock($docblock);
176 7
        $method->setParameter($parameter);
177
178 7
        $generator->addMethodFromGenerator($method);
179 7
    }
180
181 7
    private function handleGetter(Generator\ClassGenerator $generator, PHPProperty $prop, PHPClass $class)
0 ignored issues
show
Unused Code introduced by
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
182
    {
183
184 7
        if ($prop->getType() instanceof PHPClassOf) {
185 4
            $docblock = new DocBlockGenerator();
186 4
            $docblock->setShortDescription("isset " . $prop->getName());
187 4
            if ($prop->getDoc()) {
188
                $docblock->setLongDescription($prop->getDoc());
189
            }
190
191 4
            $patramTag = new ParamTag("index", "scalar");
0 ignored issues
show
Documentation introduced by
'scalar' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
192 4
            $docblock->setTag($patramTag);
193
194 4
            $docblock->setTag(new ReturnTag("boolean"));
0 ignored issues
show
Documentation introduced by
'boolean' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
195
196 4
            $paramIndex = new ParameterGenerator("index", "mixed");
197
198 4
            $method = new MethodGenerator("isset" . Inflector::classify($prop->getName()), [$paramIndex]);
199 4
            $method->setDocBlock($docblock);
200 4
            $method->setBody("return isset(\$this->" . $prop->getName() . "[\$index]);");
201 4
            $generator->addMethodFromGenerator($method);
202
203 4
            $docblock = new DocBlockGenerator();
204 4
            $docblock->setShortDescription("unset " . $prop->getName());
205 4
            if ($prop->getDoc()) {
206
                $docblock->setLongDescription($prop->getDoc());
207
            }
208
209 4
            $patramTag = new ParamTag("index", "scalar");
0 ignored issues
show
Documentation introduced by
'scalar' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
210 4
            $docblock->setTag($patramTag);
211 4
            $paramIndex = new ParameterGenerator("index", "mixed");
212
213 4
            $docblock->setTag(new ReturnTag("void"));
0 ignored issues
show
Documentation introduced by
'void' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
214
215
216 4
            $method = new MethodGenerator("unset" . Inflector::classify($prop->getName()), [$paramIndex]);
217 4
            $method->setDocBlock($docblock);
218 4
            $method->setBody("unset(\$this->" . $prop->getName() . "[\$index]);");
219 4
            $generator->addMethodFromGenerator($method);
220 4
        }
221
        // ////
222
223 7
        $docblock = new DocBlockGenerator();
224
225 7
        $docblock->setShortDescription("Gets as " . $prop->getName());
226
227 7
        if ($prop->getDoc()) {
228
            $docblock->setLongDescription($prop->getDoc());
229
        }
230
231 7
        $tag = new ReturnTag("mixed");
0 ignored issues
show
Documentation introduced by
'mixed' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
232 7
        $type = $prop->getType();
233 7
        if ($type && $type instanceof PHPClassOf) {
234 4
            $tt = $type->getArg()->getType();
235 4
            $tag->setTypes($tt->getPhpType() . "[]");
236 4 View Code Duplication
            if ($p = $tt->isSimpleType()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
237
                if (($t = $p->getType())) {
238
                    $tag->setTypes($t->getPhpType() . "[]");
239
                }
240
            }
241 7
        } elseif ($type) {
242
243 3
            if ($p = $type->isSimpleType()) {
244
                if ($t = $p->getType()) {
245
                    $tag->setTypes($t->getPhpType());
246
                }
247
            } else {
248 3
                $tag->setTypes($type->getPhpType());
249
            }
250 3
        }
251
252 7
        $docblock->setTag($tag);
253
254 7
        $method = new MethodGenerator("get" . Inflector::classify($prop->getName()));
255 7
        $method->setDocBlock($docblock);
256 7
        $method->setBody("return \$this->" . $prop->getName() . ";");
257
258 7
        $generator->addMethodFromGenerator($method);
259 7
    }
260
261 4
    private function handleAdder(Generator\ClassGenerator $generator, PHPProperty $prop, PHPClass $class)
0 ignored issues
show
Unused Code introduced by
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
262
    {
263 4
        $type = $prop->getType();
264 4
        $propName = $type->getArg()->getName();
265
266 4
        $docblock = new DocBlockGenerator();
267 4
        $docblock->setShortDescription("Adds as $propName");
268
269 4
        if ($prop->getDoc()) {
270
            $docblock->setLongDescription($prop->getDoc());
271
        }
272
273 4
        $return = new ReturnTag();
274 4
        $return->setTypes("self");
275 4
        $docblock->setTag($return);
276
277 4
        $patramTag = new ParamTag($propName, $type->getArg()->getType()->getPhpType());
278 4
        $docblock->setTag($patramTag);
279
280 4
        $method = new MethodGenerator("addTo" . Inflector::classify($prop->getName()));
281
282 4
        $parameter = new ParameterGenerator($propName);
283 4
        $tt = $type->getArg()->getType();
284
285 4
        if (!$tt->isNativeType()) {
286
287 1
            if ($p = $tt->isSimpleType()) {
288
                if (($t = $p->getType())) {
289
                    $patramTag->setTypes($t->getPhpType());
290
291
                    if (!$t->isNativeType()) {
292
                        $parameter->setType($t->getPhpType());
293
                    }
294
                }
295 1
            } elseif (!$tt->isNativeType()) {
296 1
                $parameter->setType($tt->getPhpType());
297 1
            }
298 1
        }
299
300 4
        $methodBody = "\$this->" . $prop->getName() . "[] = \$" . $propName . ";" . PHP_EOL;
301 4
        $methodBody .= "return \$this;";
302 4
        $method->setBody($methodBody);
303 4
        $method->setDocBlock($docblock);
304 4
        $method->setParameter($parameter);
305
306 4
        $generator->addMethodFromGenerator($method);
307 4
    }
308
309 7
    private function handleMethod(Generator\ClassGenerator $generator, PHPProperty $prop, PHPClass $class)
310
    {
311 7
        if ($prop->getType() instanceof PHPClassOf) {
312 4
            $this->handleAdder($generator, $prop, $class);
313 4
        }
314
315 7
        $this->handleGetter($generator, $prop, $class);
316 7
        $this->handleSetter($generator, $prop, $class);
317 7
    }
318
319 8
    private function handleProperty(Generator\ClassGenerator $class, PHPProperty $prop)
320
    {
321 8
        $generatedProp = new PropertyGenerator($prop->getName());
322 8
        $generatedProp->setVisibility(PropertyGenerator::VISIBILITY_PRIVATE);
323
324 8
        $class->addPropertyFromGenerator($generatedProp);
325
326 8
        if ($prop->getType() && (!$prop->getType()->getNamespace() && $prop->getType()->getName() == "array")) {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
327
            // $generatedProp->setDefaultValue(array(), PropertyValueGenerator::TYPE_AUTO, PropertyValueGenerator::OUTPUT_SINGLE_LINE);
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
328 4
        }
329
330 8
        $docBlock = new DocBlockGenerator();
331 8
        $generatedProp->setDocBlock($docBlock);
332
333 8
        if ($prop->getDoc()) {
334
            $docBlock->setLongDescription($prop->getDoc());
335
        }
336 8
        $tag = new PropertyTag($prop->getName(), 'mixed');
0 ignored issues
show
Documentation introduced by
'mixed' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
337
338 8
        $type = $prop->getType();
339
340 8
        if ($type && $type instanceof PHPClassOf) {
341 4
            $tt = $type->getArg()->getType();
342 4
            $tag->setTypes($tt->getPhpType() . "[]");
343 4 View Code Duplication
            if ($p = $tt->isSimpleType()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
344
                if (($t = $p->getType())) {
345
                    $tag->setTypes($t->getPhpType() . "[]");
346
                }
347
            }
348 8
        } elseif ($type) {
349
350 4
            if ($type->isNativeType()) {
351 4
                $tag->setTypes($type->getPhpType());
352 4
            } elseif (($p = $type->isSimpleType()) && ($t = $p->getType())) {
353
                $tag->setTypes($t->getPhpType());
354
            } else {
355
                $tag->setTypes($prop->getType()->getPhpType());
356
            }
357 4
        }
358 8
        $docBlock->setTag($tag);
359 8
    }
360
361 8
    public function generate(PHPClass $type)
362
    {
363 8
        $class = new \Zend\Code\Generator\ClassGenerator();
364 8
        $docblock = new DocBlockGenerator("Class representing " . $type->getName());
365 8
        if ($type->getDoc()) {
366 8
            $docblock->setLongDescription($type->getDoc());
367 8
        }
368 8
        $class->setNamespaceName($type->getNamespace() ?: NULL);
369 8
        $class->setName($type->getName());
370 8
        $class->setDocblock($docblock);
371
372 8
        if ($extends = $type->getExtends()) {
373
374 2
            if ($p = $extends->isSimpleType()) {
375 2
                $this->handleProperty($class, $p);
376 2
                $this->handleValueMethod($class, $p, $extends);
377 2
            } else {
378
379
                $class->setExtendedClass($extends->getName());
380
381
                if ($extends->getNamespace() != $type->getNamespace()) {
382
                    if ($extends->getName() == $type->getName()) {
383
                        $class->addUse($type->getExtends()
384
                            ->getFullName(), $extends->getName() . "Base");
385
                        $class->setExtendedClass($extends->getName() . "Base");
386
                    } else {
387
                        $class->addUse($extends->getFullName());
388
                    }
389
                }
390
            }
391 2
        }
392
393 8
        if ($this->handleBody($class, $type)) {
394 8
            return $class;
395
        }
396
    }
397
}
398