Completed
Push — master ( 44b0be...4a5c62 )
by Daniel
02:13
created

AbstractReader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 40
ccs 0
cts 7
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getStream() 0 4 1
read() 0 1 ?
1
<?php
2
/**
3
 * This file is part of the stream package
4
 *
5
 * @author Daniel Schröder <[email protected]>
6
 */
7
8
namespace GravityMedia\Stream\Reader;
9
10
use GravityMedia\Stream\Exception;
11
use GravityMedia\Stream\StreamInterface;
12
13
/**
14
 * Abstract reader
15
 *
16
 * @package GravityMedia\Stream\Reader
17
 */
18
abstract class AbstractReader
19
{
20
    /**
21
     * @var StreamInterface
22
     */
23
    protected $stream;
24
25
    /**
26
     * Create reader object
27
     *
28
     * @throws Exception\InvalidArgumentException An exception will be thrown for non-readable streams
29
     *
30
     * @param StreamInterface $stream
31
     */
32
    public function __construct(StreamInterface $stream)
33
    {
34
        if (!$stream->isReadable()) {
35
            throw new Exception\InvalidArgumentException('Stream not readable');
36
        }
37
38
        $this->stream = $stream;
39
    }
40
41
    /**
42
     * Get stream
43
     *
44
     * @return StreamInterface
45
     */
46
    public function getStream()
47
    {
48
        return $this->stream;
49
    }
50
51
    /**
52
     * Read data from the stream
53
     *
54
     * @return mixed
55
     */
56
    abstract public function read();
57
}
58