AbstractStream   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 9
Bugs 0 Features 1
Metric Value
wmc 2
c 9
b 0
f 1
lcom 1
cbo 1
dl 0
loc 34
ccs 5
cts 5
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
__construct() 0 1 ?
A getBuffer() 0 4 1
A skip() 0 4 1
1
<?php
2
3
namespace Zerg\Stream;
4
5
/**
6
 * AbstractStream represents any type of stream - an entity that wraps data source and
7
 * encapsulates the read and write operations.
8
 *
9
 * @since 0.1
10
 * @package Zerg\Stream
11
 */
12
abstract class AbstractStream
13
{
14
    /**
15
     * @var \PhpBio\BitBuffer Object that reads and writes data from|to file|memory stream.
16
     * */
17
    protected $buffer;
18
19
    /**
20
     * Implementations should init buffer itself by given value.
21
     *
22
     * @param string $path Value to init buffer.
23
     */
24
    abstract public function __construct($path);
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
25
26
    /**
27
     * Getter for $buffer property.
28
     *
29
     * @return \PhpBio\BitBuffer Object that reads data from file|memory stream.
30
     */
31 26
    public function getBuffer()
32
    {
33 26
        return $this->buffer;
34
    }
35
36
    /**
37
     * Move internal pointer by given amount of bits ahead without reading dta.
38
     *
39
     * @param int $size Amount of bits to be skipped.
40
     */
41 7
    public function skip($size)
42
    {
43 7
        $this->buffer->setPosition($this->buffer->getPosition() + $size);
44
    }
45
}