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

RawStreamReader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 30
wmc 4
lcom 1
cbo 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getContents() 0 4 1
A getContentsAsStream() 0 4 1
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