Conditions | 10 |
Paths | 6 |
Total Lines | 28 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
29 | public function getUploadSize($path) { |
||
30 | $uploadSize = null; |
||
31 | |||
32 | $requestMethod = $this->request->getMethod(); |
||
33 | $isRemoteScript = $this->isScriptName('remote.php'); |
||
34 | $isPublicScript = $this->isScriptName('public.php'); |
||
35 | // Are we uploading anything? |
||
36 | if (in_array($requestMethod, ['MOVE', 'PUT']) && $isRemoteScript) { |
||
37 | // v1 && v2 Chunks are not scanned |
||
38 | if ($requestMethod === 'PUT' && strpos($path, 'uploads/') === 0) { |
||
39 | return null; |
||
40 | } |
||
41 | |||
42 | if (\OC_FileChunking::isWebdavChunk() && strpos($path, 'cache/') === 0) { |
||
43 | return null; |
||
44 | } |
||
45 | |||
46 | if ($requestMethod === 'PUT') { |
||
47 | $uploadSize = (int)$this->request->getHeader('CONTENT_LENGTH'); |
||
48 | } else { |
||
49 | $uploadSize = (int)$this->request->getHeader('OC_TOTAL_LENGTH'); |
||
50 | } |
||
51 | } else if ($requestMethod === 'PUT' && $isPublicScript) { |
||
52 | $uploadSize = (int)$this->request->getHeader('CONTENT_LENGTH'); |
||
53 | } |
||
54 | |||
55 | return $uploadSize; |
||
56 | } |
||
57 | |||
68 |