1
|
|
|
<?php /** @var \Puli\Manager\Api\Php\Clazz $class */ ?> |
2
|
|
|
|
3
|
|
|
<?php if ($class->getNamespaceName()): ?> |
4
|
|
|
namespace <?php echo $class->getNamespaceName() ?>; |
5
|
|
|
|
6
|
|
|
<?php endif ?> |
7
|
|
|
<?php if ($class->hasImports()): ?> |
8
|
|
|
<?php foreach ($class->getImports() as $import): ?> |
9
|
|
|
<?php if ($class->getNamespaceName() !== $import->getNamespaceName()): ?> |
10
|
|
|
use <?php echo $import ?>; |
11
|
|
|
<?php endif ?> |
12
|
|
|
<?php endforeach ?> |
13
|
|
|
|
14
|
|
|
<?php endif ?> |
15
|
|
|
<?php if ($class->getDescription()): ?> |
16
|
|
|
/** |
17
|
|
|
<?php foreach (explode("\n", $class->getDescription()) as $line): ?> |
18
|
|
|
*<?php echo rtrim(' '.$line)."\n" ?> |
19
|
|
|
<?php endforeach ?> |
20
|
|
|
*/ |
21
|
|
|
<?php endif ?> |
22
|
|
|
class <?php echo $class->getShortClassName() ?><?php if ($class->hasParentClass()): ?> extends <?php echo $class->getParentClass() ?><?php endif ?><?php if ($class->hasImplementedInterfaces()): ?> implements <?php echo implode(', ', $class->getImplementedInterfaces()) ?><?php endif ?><?php echo "\n" ?> |
23
|
|
|
{ |
24
|
|
|
<?php $first = true ?> |
25
|
|
|
<?php foreach ($class->getMethods() as $method): ?> |
26
|
|
|
<?php if (!$first) echo "\n" ?> |
27
|
|
|
<?php if ($method->getDescription() || $method->hasArguments() || $method->hasReturnValue()): ?> |
28
|
|
|
/** |
29
|
|
View Code Duplication |
<?php if ($method->getDescription()): ?> |
|
|
|
|
30
|
|
|
<?php foreach (explode("\n", $method->getDescription()) as $line): ?> |
31
|
|
|
*<?php echo rtrim(' '.$line)."\n" ?> |
32
|
|
|
<?php endforeach ?> |
33
|
|
|
<?php endif ?> |
34
|
|
|
<?php if ($method->getDescription() && ($method->hasArguments() || $method->hasReturnValue())): ?> |
35
|
|
|
* |
36
|
|
|
<?php endif ?> |
37
|
|
|
<?php if ($method->hasArguments()): ?> |
38
|
|
|
<?php foreach ($method->getArguments() as $arg): ?> |
39
|
|
|
* @param <?php echo $arg->getType() ?> $<?php echo $arg->getName() ?><?php if ($arg->getDescription()): ?> <?php echo $arg->getDescription() ?><?php endif ?><?php echo "\n" ?> |
40
|
|
|
<?php endforeach ?> |
41
|
|
|
<?php endif ?> |
42
|
|
|
<?php if ($method->hasArguments() && $method->hasReturnValue()): ?> |
43
|
|
|
* |
44
|
|
|
<?php endif ?> |
45
|
|
|
<?php if ($method->hasReturnValue()): ?> |
46
|
|
|
* @return <?php echo $method->getReturnValue()->getType() ?><?php if ($method->getReturnValue()->getDescription()): ?> <?php echo $method->getReturnValue()->getDescription() ?><?php endif ?><?php echo "\n" ?> |
47
|
|
|
<?php endif ?> |
48
|
|
|
*/ |
49
|
|
|
<?php endif ?> |
50
|
|
|
public function <?php echo $method->getName() ?>(<?php echo implode(', ', $method->getArguments()) ?>) |
51
|
|
|
{ |
52
|
|
View Code Duplication |
<?php if ($method->getBody()): ?> |
|
|
|
|
53
|
|
|
<?php foreach (explode("\n", $method->getBody()) as $line): ?> |
54
|
|
|
<?php echo rtrim(' '.$line)."\n" ?> |
55
|
|
|
<?php endforeach ?> |
56
|
|
|
<?php endif ?> |
57
|
|
|
<?php if ($method->getBody() && $method->hasReturnValue()) echo "\n" ?> |
58
|
|
|
<?php if ($method->hasReturnValue()): ?> |
59
|
|
|
return <?php echo $method->getReturnValue() ?>; |
60
|
|
|
<?php endif ?> |
61
|
|
|
} |
62
|
|
|
<?php $first = false ?> |
63
|
|
|
<?php endforeach ?> |
64
|
|
|
} |
65
|
|
|
|
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.