Conditions | 11 |
Paths | 7 |
Total Lines | 32 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | 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 |
||
48 | public function getUploadSize($path) { |
||
49 | $cachedSize = $this->fileSizeCache->get($path); |
||
50 | if ($cachedSize > 0) { |
||
51 | return $cachedSize; |
||
52 | } |
||
53 | |||
54 | $uploadSize = null; |
||
55 | $requestMethod = $this->request->getMethod(); |
||
56 | $isRemoteScript = $this->isScriptName('remote.php'); |
||
57 | $isPublicScript = $this->isScriptName('public.php'); |
||
58 | // Are we uploading anything? |
||
59 | if (\in_array($requestMethod, ['PUT']) && $isRemoteScript) { |
||
60 | // v1 && v2 Chunks are not scanned |
||
61 | if ($requestMethod === 'PUT' && \strpos($path, 'uploads/') === 0) { |
||
62 | return null; |
||
63 | } |
||
64 | |||
65 | if (\OC_FileChunking::isWebdavChunk() && \strpos($path, 'cache/') === 0) { |
||
66 | return null; |
||
67 | } |
||
68 | |||
69 | if ($requestMethod === 'PUT') { |
||
70 | $uploadSize = (int)$this->request->getHeader('CONTENT_LENGTH'); |
||
71 | } else { |
||
72 | $uploadSize = (int)$this->request->getHeader('OC_TOTAL_LENGTH'); |
||
73 | } |
||
74 | } else if ($requestMethod === 'PUT' && $isPublicScript) { |
||
75 | $uploadSize = (int)$this->request->getHeader('CONTENT_LENGTH'); |
||
76 | } |
||
77 | |||
78 | return $uploadSize; |
||
79 | } |
||
80 | |||
92 |