Completed
Branch releases/v0.2 (da7ff5)
by Luke
02:45
created

IsSeekable::seek()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 1
ccs 0
cts 0
cp 0
nc 1
1
<?php
2
/**
3
 * CSVelte: Slender, elegant CSV for PHP.
4
 *
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   v0.2
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
18
/**
19
 * IO IsSeekable Trait.
20
 *
21
 * Seek methods shared between CSVelte\IO classes.
22
 *
23
 * @package    CSVelte
24
 * @subpackage CSVelte\Traits
25
 * @copyright  (c) 2016, Luke Visinoni <[email protected]>
26
 * @author     Luke Visinoni <[email protected]>
27
 * @since      v0.2
28
 */
29
trait IsSeekable
30
{
31
    /**
32
     * Seek to specific line (beginning).
33
     *
34
     * Seek to the line specified by $offset, starting from the $whence line.
35
     *
36
     * @param int $offset Offset to seek to
37
     * @param int $whence Position from whence to seek from
38
     * @param string $eol The line terminator string/char
39
     * @return boolean True if successful
40
     * @throws CSVelte\Exception\NotYetImplementedException because it isn't
41
     *     implemented yet
42
     */
43
    public function seekLine($offset, $whence = SEEK_SET, $eol = PHP_EOL)
3 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...
44
    {
45
        throw new NotYetImplementedException("This method not yet implemented.");
46
    }
47
48
    /**
49
     * Assert that this file/stream object is readable.
50
     *
51
     * @return void
52
     * @throws CSVelte\Exception\IOException if stream isn't readable
53
     */
54 2
    protected function assertIsSeekable()
55
    {
56 2
        if (!$this->isSeekable()) {
57
            throw new IOException("Stream not seekable: " . $this->getName(), IOException::ERR_NOT_SEEKABLE);
58
        }
59 2
    }
60
61
    abstract public function getName();
62
63
    abstract public function isSeekable();
1 ignored issue
show
Best Practice introduced by
Using PHP4-style constructors that are named like the class is not recommend; better use the more explicit __construct method.
Loading history...
64
65
    abstract public function seek($offset, $whence);
66
67
}
68