| Total Lines | 75 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 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 |
||
| 67 | 9 | public function getBody(): StreamInterface |
|
| 68 | { |
||
| 69 | 9 | return new class() implements StreamInterface { |
|
| 70 | public function __toString(): string |
||
| 71 | { |
||
| 72 | 1 | throw new RuntimeException('Method "__toString" is not supported.'); |
|
| 73 | } |
||
| 74 | |||
| 75 | public function close(): void |
||
| 76 | { |
||
| 77 | 1 | } |
|
| 78 | |||
| 79 | public function detach() |
||
| 80 | { |
||
| 81 | 1 | return null; |
|
| 82 | } |
||
| 83 | |||
| 84 | public function getSize(): ?int |
||
| 85 | { |
||
| 86 | 1 | return null; |
|
| 87 | } |
||
| 88 | |||
| 89 | public function tell(): int |
||
| 90 | { |
||
| 91 | 1 | throw new RuntimeException('Method "tell" is not supported.'); |
|
| 92 | } |
||
| 93 | |||
| 94 | public function eof(): bool |
||
| 95 | { |
||
| 96 | 1 | return false; |
|
| 97 | } |
||
| 98 | |||
| 99 | public function isSeekable(): bool |
||
| 100 | { |
||
| 101 | 1 | return false; |
|
| 102 | } |
||
| 103 | |||
| 104 | public function seek(int $offset, int $whence = SEEK_SET): void |
||
| 105 | { |
||
| 106 | 1 | throw new RuntimeException('Method "seek" is not supported.'); |
|
| 107 | } |
||
| 108 | |||
| 109 | public function rewind(): void |
||
| 110 | { |
||
| 111 | 1 | throw new RuntimeException('Method "rewind" is not supported.'); |
|
| 112 | } |
||
| 113 | |||
| 114 | public function isWritable(): bool |
||
| 115 | { |
||
| 116 | 1 | return false; |
|
| 117 | } |
||
| 118 | |||
| 119 | public function write(string $string): void |
||
| 120 | { |
||
| 121 | 1 | throw new RuntimeException('Method "write" is not supported.'); |
|
| 122 | } |
||
| 123 | |||
| 124 | public function isReadable(): bool |
||
| 125 | { |
||
| 126 | 2 | return false; |
|
| 127 | } |
||
| 128 | |||
| 129 | public function read(int $length): void |
||
| 130 | { |
||
| 131 | 1 | throw new RuntimeException('Method "read" is not supported.'); |
|
| 132 | } |
||
| 133 | |||
| 134 | public function getContents(): void |
||
| 135 | { |
||
| 136 | 1 | throw new RuntimeException('Method "getContents" is not supported.'); |
|
| 137 | } |
||
| 138 | |||
| 139 | public function getMetadata(?string $key = null): mixed |
||
| 140 | { |
||
| 141 | 1 | return null; |
|
| 142 | } |
||
| 166 |