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
|
|
|
* @copyright Copyright (c) 2018 Luke Visinoni |
10
|
|
|
* @author Luke Visinoni <[email protected]> |
11
|
|
|
* @license See LICENSE file (MIT license) |
12
|
|
|
*/ |
13
|
|
|
namespace CSVelte\Traits; |
14
|
|
|
|
15
|
|
|
use CSVelte\Exception\IOException; |
16
|
|
|
use CSVelte\Exception\NotYetImplementedException; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* IO IsSeekable Trait. |
20
|
|
|
* |
21
|
|
|
* Seek methods shared between CSVelte\IO classes. |
22
|
|
|
*/ |
23
|
|
|
trait IsSeekable |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Seek to specific line (beginning). |
27
|
|
|
* |
28
|
|
|
* Seek to the line specified by $offset, starting from the $whence line. |
29
|
|
|
* |
30
|
|
|
* @param int $offset Offset to seek to |
31
|
|
|
* @param int $whence Position from whence to seek from |
32
|
|
|
* @param string $eol The line terminator string/char |
33
|
|
|
* |
34
|
|
|
* @throws NotYetImplementedException |
35
|
|
|
* |
36
|
|
|
* @return bool True if successful |
37
|
|
|
*/ |
38
|
1 |
|
public function seekLine($offset, $whence = SEEK_SET, $eol = PHP_EOL) |
|
|
|
|
39
|
|
|
{ |
40
|
1 |
|
throw new NotYetImplementedException('This method not yet implemented.'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
abstract public function isSeekable(); |
44
|
|
|
|
45
|
|
|
abstract public function seek($offset, $whence = SEEK_SET); |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Assert that this file/stream object is readable. |
49
|
|
|
* |
50
|
|
|
* @throws IOException |
51
|
|
|
*/ |
52
|
7 |
|
protected function assertIsSeekable() |
53
|
|
|
{ |
54
|
7 |
|
if (!$this->isSeekable()) { |
55
|
2 |
|
throw new IOException('Stream not seekable', IOException::ERR_NOT_SEEKABLE); |
56
|
|
|
} |
57
|
6 |
|
} |
58
|
|
|
} |
59
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.