Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions src/UploadedFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace React\Http;

use React\Stream\ReadableStreamInterface;

/**
* @internal
*/
class UploadedFile implements UploadedFileInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be @internal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes 👍

{
/**
* @var string
*/
protected $filename;

/**
* @var string
*/
protected $contentType;

/**
* @var ReadableStreamInterface
*/
protected $stream;

/**
* @param string $filename
* @param string $contentType
* @param ReadableStreamInterface $stream
*/
public function __construct($filename, $contentType, ReadableStreamInterface $stream)
{
$this->filename = $filename;
$this->contentType = $contentType;
$this->stream = $stream;
}

/**
* @return string
*/
public function getClientFilename()
{
return $this->filename;
}

/**
* @return string
*/
public function getClientMediaType()
{
return $this->contentType;
}

/**
* @return ReadableStreamInterface
*/
public function getStream()
{
return $this->stream;
}
}
23 changes: 23 additions & 0 deletions src/UploadedFileInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace React\Http;

use React\Stream\ReadableStreamInterface;

interface UploadedFileInterface
{
/**
* @return string
*/
public function getClientFilename();

/**
* @return string
*/
public function getClientMediaType();

/**
* @return ReadableStreamInterface
*/
public function getStream();
}
20 changes: 20 additions & 0 deletions tests/UploadedFileTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace React\Tests\Http;

use React\Http\UploadedFile;
use React\Stream\ThroughStream;

class UploadedFileTest extends TestCase
{
public function testGetters()
{
$filename = 'bar.txt';
$type = 'text/text';
$stream = new ThroughStream();
$file = new UploadedFile($filename, $type, $stream);
$this->assertEquals($filename, $file->getClientFilename());
$this->assertEquals($type, $file->getClientMediaType());
$this->assertEquals($stream, $file->getStream());
}
}