IsSeekable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
dl 0
loc 36
ccs 4
cts 6
cp 0.6667
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
isSeekable() 0 1 ?
seek() 0 1 ?
A seekLine() 0 4 1
A assertIsSeekable() 0 6 2
1
<?php
2
3
/*
4
 * CSVelte: Slender, elegant CSV for PHP
5
 * Inspired by Python's CSV module and Frictionless Data and the W3C's CSV
6
 * standardization efforts, CSVelte was written in an effort to take all the
7
 * suck out of working with CSV.
8
 *
9
 * @version   {version}
10
 * @copyright Copyright (c) 2016 Luke Visinoni <[email protected]>
11
 * @author    Luke Visinoni <[email protected]>
12
 * @license   https://github.com/deni-zen/csvelte/blob/master/LICENSE The MIT License (MIT)
13
 */
14
namespace CSVelte\Traits;
15
16
use CSVelte\Exception\IOException;
17
use CSVelte\Exception\NotYetImplementedException;
18
19
/**
20
 * IO IsSeekable Trait.
21
 *
22
 * Seek methods shared between CSVelte\IO classes.
23
 *
24
 * @package    CSVelte
25
 * @subpackage CSVelte\Traits
26
 *
27
 * @copyright  (c) 2016, Luke Visinoni <[email protected]>
28
 * @author     Luke Visinoni <[email protected]>
29
 *
30
 * @since      v0.2
31
 */
32
trait IsSeekable
33
{
34
    /**
35
     * Seek to specific line (beginning).
36
     *
37
     * Seek to the line specified by $offset, starting from the $whence line.
38
     *
39
     * @param int    $offset Offset to seek to
40
     * @param int    $whence Position from whence to seek from
41
     * @param string $eol    The line terminator string/char
42
     *
43
     * @throws NotYetImplementedException
44
     *
45
     * @return bool True if successful
46
     */
47
    public function seekLine($offset, $whence = SEEK_SET, $eol = PHP_EOL)
0 ignored issues
show
Unused Code introduced by
The parameter $offset is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $whence is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $eol is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
48
    {
49
        throw new NotYetImplementedException('This method not yet implemented.');
50
    }
51
52
    abstract public function isSeekable();
53
54
    abstract public function seek($offset, $whence = SEEK_SET);
55
56
    /**
57
     * Assert that this file/stream object is readable.
58
     *
59
     * @throws IOException
60
     */
61 10
    protected function assertIsSeekable()
62
    {
63 10
        if (!$this->isSeekable()) {
64 2
            throw new IOException('Stream not seekable', IOException::ERR_NOT_SEEKABLE);
65
        }
66 9
    }
67
}
68