File tree Expand file tree Collapse file tree 3 files changed +102
-0
lines changed Expand file tree Collapse file tree 3 files changed +102
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace React \Http ;
4+
5+ use React \Stream \ReadableStreamInterface ;
6+
7+ class File implements FileInterface
8+ {
9+ /**
10+ * @var string
11+ */
12+ protected $ filename ;
13+
14+ /**
15+ * @var string
16+ */
17+ protected $ contentType ;
18+
19+ /**
20+ * @var ReadableStreamInterface
21+ */
22+ protected $ stream ;
23+
24+ /**
25+ * @param string $filename
26+ * @param string $contentType
27+ * @param ReadableStreamInterface $stream
28+ */
29+ public function __construct ($ filename , $ contentType , ReadableStreamInterface $ stream )
30+ {
31+ $ this ->filename = $ filename ;
32+ $ this ->contentType = $ contentType ;
33+ $ this ->stream = $ stream ;
34+ }
35+
36+ /**
37+ * @return string
38+ */
39+ public function getFilename ()
40+ {
41+ return $ this ->filename ;
42+ }
43+
44+ /**
45+ * @return string
46+ */
47+ public function getContentType ()
48+ {
49+ return $ this ->contentType ;
50+ }
51+
52+ /**
53+ * @return ReadableStreamInterface
54+ */
55+ public function getStream ()
56+ {
57+ return $ this ->stream ;
58+ }
59+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace React \Http ;
4+
5+ use React \Stream \ReadableStreamInterface ;
6+
7+ interface FileInterface
8+ {
9+ /**
10+ * @return string
11+ */
12+ public function getFilename ();
13+
14+ /**
15+ * @return string
16+ */
17+ public function getContentType ();
18+
19+ /**
20+ * @return ReadableStreamInterface
21+ */
22+ public function getStream ();
23+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace React \Tests \Http ;
4+
5+ use React \Http \File ;
6+ use React \Stream \ThroughStream ;
7+
8+ class FileTest extends TestCase
9+ {
10+ public function testGetters ()
11+ {
12+ $ filename = 'bar.txt ' ;
13+ $ type = 'text/text ' ;
14+ $ stream = new ThroughStream ();
15+ $ file = new File ($ filename , $ type , $ stream );
16+ $ this ->assertEquals ($ filename , $ file ->getFilename ());
17+ $ this ->assertEquals ($ type , $ file ->getContentType ());
18+ $ this ->assertEquals ($ stream , $ file ->getStream ());
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments