Completed
Branch full-rewrite (4754d3)
by Thibaud
03:13
created

RawStreamReader::getContentsAsStream()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Alchemy\Zippy\Resource\Reader;
4
5
use Alchemy\Zippy\Resource\ResourceReader;
6
7
class RawStreamReader implements ResourceReader
8
{
9
10
    private $stream;
11
12
    public function __construct($resource)
13
    {
14
        if (! is_resource($resource)) {
15
            throw new \InvalidArgumentException('Invalid resource.');
16
        }
17
18
        $this->stream = $resource;
19
    }
20
21
    /**
22
     * @return string
23
     */
24
    public function getContents()
25
    {
26
        return stream_get_contents($this->stream);
27
    }
28
29
    /**
30
     * @return resource
31
     */
32
    public function getContentsAsStream()
33
    {
34
        return $this->stream;
35
    }
36
}
37