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