Skip to content

Commit

Permalink
change uploadFile impl.
Browse files Browse the repository at this point in the history
  • Loading branch information
BMTmohammedtaha committed Jul 24, 2023
1 parent b736e82 commit 18aae41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/ServerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function withQueryParams(array $query): static
*/
public function getUploadedFiles(): array
{
return $_FILES;
return $this->uploadedFiles;
}
/**
* Returns an instance with the specified uploaded files.
Expand Down
16 changes: 9 additions & 7 deletions src/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Effectra\Http\Message;

use Psr\Http\Message\UploadedFileInterface;
use Psr\Http\Message\StreamInterface;
use RuntimeException;

/**
Expand Down Expand Up @@ -68,7 +69,7 @@ public function __construct($file, $size, $error, $name = null, $type = null)
*
* @return int|null The file size in bytes or null if unknown
*/
public function getSize()
public function getSize():int|null
{
return $this->size;
}
Expand All @@ -77,7 +78,7 @@ public function getSize()
*
* @return int The file upload error code
*/
public function getError()
public function getError():int
{
return $this->error;
}
Expand All @@ -86,7 +87,7 @@ public function getError()
*
* @return string|null The client-provided file name or null if not provided
*/
public function getClientFilename()
public function getClientFilename():string|null
{
return $this->name;
}
Expand All @@ -96,7 +97,7 @@ public function getClientFilename()
*
* @return string|null The client-provided media type of the file or null if not provided
*/
public function getClientMediaType()
public function getClientMediaType():string|null
{
return $this->type;
}
Expand All @@ -106,7 +107,7 @@ public function getClientMediaType()
* @return StreamInterface The uploaded file stream
* @throws RuntimeException If the file has been moved or the stream cannot be created
*/
public function getStream()
public function getStream():StreamInterface
{
if ($this->moved) {
throw new RuntimeException('Stream is no longer available');
Expand All @@ -123,8 +124,9 @@ public function getStream()
*
* @param string $targetPath The target path to move the uploaded file to
* @throws RuntimeException If the file has already been moved, is not an uploaded file, or an error occurs during the move operation
* @return void
*/
public function moveTo($targetPath)
public function moveTo($targetPath):void
{
if ($this->moved) {
throw new RuntimeException('File has already been moved');
Expand All @@ -145,7 +147,7 @@ public function moveTo($targetPath)
*
* @return bool True if the file has been moved, false otherwise
*/
public function isMoved()
public function isMoved():bool
{
return $this->moved;
}
Expand Down

0 comments on commit 18aae41

Please sign in to comment.