| Conditions | 3 |
| Paths | 3 |
| Total Lines | 25 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 3 | public function receive($name) |
|
| 18 | { |
||
| 19 | 3 | $uploadedFile = $this->request->file($name); |
|
| 20 | 3 | $chunks = $this->request->get('chunks'); |
|
| 21 | 3 | if (empty($chunks) === true) { |
|
| 22 | 1 | return $uploadedFile; |
|
| 23 | } |
||
| 24 | 2 | $chunk = $this->request->get('chunk'); |
|
| 25 | |||
| 26 | 2 | $originalName = $this->request->get('name'); |
|
| 27 | 2 | $start = $chunk * $this->request->header('content-length'); |
|
| 28 | 2 | $completed = $chunk >= $chunks - 1; |
|
| 29 | |||
| 30 | 2 | $this->chunkFile |
|
|
|
|||
| 31 | 2 | ->setToken($this->request->get('token')) |
|
| 32 | 2 | ->setChunkPath($this->chunkPath()) |
|
| 33 | 2 | ->setStoragePath($this->storagePath()) |
|
| 34 | 2 | ->setName($originalName) |
|
| 35 | 2 | ->setMimeType($uploadedFile->getMimeType()) |
|
| 36 | 2 | ->appendStream($uploadedFile->getPathname(), $start); |
|
| 37 | |||
| 38 | return $completed === true |
||
| 39 | 2 | ? $this->chunkFile->createUploadedFile() |
|
| 40 | 2 | : $this->chunkFile->throwException(); |
|
| 41 | } |
||
| 42 | |||
| 60 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: