| Conditions | 10 |
| Paths | 24 |
| Total Lines | 32 |
| Code Lines | 20 |
| 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 |
||
| 52 | public function resolve($path, $flags = null) |
||
| 53 | { |
||
| 54 | $hasPharPrefix = Helper::hasPharPrefix($path); |
||
| 55 | if ($flags === null) { |
||
| 56 | $flags = static::RESOLVE_REALPATH | static::RESOLVE_ALIAS | static::ASSERT_INTERNAL_INVOCATION; |
||
| 57 | } |
||
| 58 | |||
| 59 | if ($hasPharPrefix && $flags & static::RESOLVE_ALIAS) { |
||
| 60 | $invocation = $this->findByAlias($path); |
||
| 61 | if ($invocation !== null && $this->assertInternalInvocation($invocation, $flags)) { |
||
| 62 | return $invocation; |
||
| 63 | } elseif ($invocation !== null) { |
||
| 64 | return null; |
||
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | $baseName = Helper::determineBaseFile($path); |
||
| 69 | if ($baseName === null) { |
||
| 70 | return null; |
||
| 71 | } |
||
| 72 | |||
| 73 | if ($flags & static::RESOLVE_REALPATH) { |
||
| 74 | $baseName = realpath($baseName); |
||
| 75 | } |
||
| 76 | if ($flags & static::RESOLVE_ALIAS) { |
||
| 77 | $reader = new Reader($baseName); |
||
| 78 | $alias = $reader->resolveContainer()->getAlias(); |
||
| 79 | } else { |
||
| 80 | $alias = ''; |
||
| 81 | } |
||
| 82 | |||
| 83 | return new PharInvocation($baseName, $alias); |
||
| 84 | } |
||
| 138 |