-
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef71d49
commit 644aed4
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace React\Http; | ||
|
||
use React\Stream\ReadableStreamInterface; | ||
|
||
class File implements FileInterface | ||
{ | ||
/** | ||
* @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 getFilename() | ||
{ | ||
return $this->filename; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getContentType() | ||
{ | ||
return $this->contentType; | ||
} | ||
|
||
/** | ||
* @return ReadableStreamInterface | ||
*/ | ||
public function getStream() | ||
{ | ||
return $this->stream; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace React\Http; | ||
|
||
use React\Stream\ReadableStreamInterface; | ||
|
||
interface FileInterface | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getFilename(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getContentType(); | ||
|
||
/** | ||
* @return ReadableStreamInterface | ||
*/ | ||
public function getStream(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace React\Tests\Http; | ||
|
||
use React\Http\File; | ||
use React\Stream\ThroughStream; | ||
|
||
class FileTest extends TestCase | ||
{ | ||
public function testGetters() | ||
{ | ||
$filename = 'bar.txt'; | ||
$type = 'text/text'; | ||
$stream = new ThroughStream(); | ||
$file = new File($filename, $type, $stream); | ||
$this->assertEquals($filename, $file->getFilename()); | ||
$this->assertEquals($type, $file->getContentType()); | ||
$this->assertEquals($stream, $file->getStream()); | ||
} | ||
} |