Conditions | 12 |
Paths | 192 |
Total Lines | 71 |
Code Lines | 45 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
50 | public function resolveDepsInternalTag(\ReflectionClass $reflectionClass): array |
||
51 | { |
||
52 | $ret = []; |
||
53 | |||
54 | if ($this->haveTag($reflectionClass, self::DEPS_INTERNAL)) { |
||
55 | try { |
||
56 | $ret[] = new DepsInternal( |
||
57 | FQSEN::createClass($reflectionClass->getName()), |
||
58 | $this->resolve($reflectionClass->getDocComment(), self::DEPS_INTERNAL) |
||
|
|||
59 | ); |
||
60 | } catch (InvalidFullyQualifiedStructureElementNameException $e) { |
||
61 | DependencyDumper::getObserver()->notifyResolvePhpDocError( |
||
62 | $reflectionClass->getFileName(), |
||
63 | FQSEN::createClass($reflectionClass->getName()), |
||
64 | $e |
||
65 | ); |
||
66 | } |
||
67 | } |
||
68 | |||
69 | foreach ($reflectionClass->getProperties() as $reflectionProperty) { |
||
70 | if ($this->haveTag($reflectionProperty, self::DEPS_INTERNAL)) { |
||
71 | try { |
||
72 | $ret[] = new DepsInternal( |
||
73 | FQSEN::createProperty($reflectionClass->getName(), $reflectionProperty->getName()), |
||
74 | $this->resolve($reflectionProperty->getDocComment(), self::DEPS_INTERNAL) |
||
75 | ); |
||
76 | } catch (InvalidFullyQualifiedStructureElementNameException $e) { |
||
77 | DependencyDumper::getObserver()->notifyResolvePhpDocError( |
||
78 | $reflectionClass->getFileName(), |
||
79 | FQSEN::createClass($reflectionClass->getName()), |
||
80 | $e |
||
81 | ); |
||
82 | } |
||
83 | } |
||
84 | } |
||
85 | |||
86 | foreach ($reflectionClass->getMethods() as $reflectionMethod) { |
||
87 | if ($this->haveTag($reflectionMethod, self::DEPS_INTERNAL)) { |
||
88 | try { |
||
89 | $ret[] = new DepsInternal( |
||
90 | FQSEN::createMethod($reflectionClass->getName(), $reflectionMethod->getName()), |
||
91 | $this->resolve($reflectionMethod->getDocComment(), self::DEPS_INTERNAL) |
||
92 | ); |
||
93 | } catch (InvalidFullyQualifiedStructureElementNameException $e) { |
||
94 | DependencyDumper::getObserver()->notifyResolvePhpDocError( |
||
95 | $reflectionClass->getFileName(), |
||
96 | FQSEN::createClass($reflectionClass->getName()), |
||
97 | $e |
||
98 | ); |
||
99 | } |
||
100 | } |
||
101 | } |
||
102 | |||
103 | foreach ($reflectionClass->getReflectionConstants() as $reflectionClassConstant) { |
||
104 | if ($this->haveTag($reflectionClassConstant, self::DEPS_INTERNAL)) { |
||
105 | try { |
||
106 | $ret[] = new DepsInternal( |
||
107 | FQSEN::createClassConstant($reflectionClass->getName(), $reflectionClassConstant->getName()), |
||
108 | $this->resolve($reflectionClassConstant->getDocComment(), self::DEPS_INTERNAL) |
||
109 | ); |
||
110 | } catch (InvalidFullyQualifiedStructureElementNameException $e) { |
||
111 | DependencyDumper::getObserver()->notifyResolvePhpDocError( |
||
112 | $reflectionClass->getFileName(), |
||
113 | FQSEN::createClass($reflectionClass->getName()), |
||
114 | $e |
||
115 | ); |
||
116 | } |
||
117 | } |
||
118 | } |
||
119 | |||
120 | return $ret; |
||
121 | } |
||
230 |