Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Making UploadedFile extend SplFileInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsah authored and weierophinney committed Nov 12, 2019
1 parent 8db5e63 commit bfe7a22
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Zend\Diactoros;

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

Expand All @@ -35,7 +36,7 @@
use const UPLOAD_ERR_OK;
use const UPLOAD_ERR_PARTIAL;

class UploadedFile implements UploadedFileInterface
class UploadedFile extends SplFileInfo implements UploadedFileInterface
{
const ERROR_MESSAGES = [
UPLOAD_ERR_OK => 'There is no error, the file uploaded with success',
Expand Down Expand Up @@ -102,9 +103,13 @@ public function __construct(
if ($errorStatus === UPLOAD_ERR_OK) {
if (is_string($streamOrFile)) {
$this->file = $streamOrFile;

parent::__construct($this->file);
}
if (is_resource($streamOrFile)) {
$this->stream = new Stream($streamOrFile);

parent::__construct($this->stream->getMetaData('uri'));
}

if (! $this->file && ! $this->stream) {
Expand Down

0 comments on commit bfe7a22

Please sign in to comment.