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.1 |
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
|
|
|
* @copyright (c) 2016, Luke Visinoni <[email protected]> |
27
|
|
|
* @author Luke Visinoni <[email protected]> |
28
|
|
|
* @since v0.2 |
29
|
|
|
*/ |
30
|
|
|
trait IsSeekable |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* Seek to specific line (beginning). |
34
|
|
|
* |
35
|
|
|
* Seek to the line specified by $offset, starting from the $whence line. |
36
|
|
|
* |
37
|
|
|
* @param int $offset Offset to seek to |
38
|
|
|
* @param int $whence Position from whence to seek from |
39
|
|
|
* @param string $eol The line terminator string/char |
40
|
|
|
* @return boolean True if successful |
41
|
|
|
* @throws CSVelte\Exception\NotYetImplementedException because it isn't |
42
|
|
|
* implemented yet |
43
|
|
|
*/ |
44
|
1 |
|
public function seekLine($offset, $whence = SEEK_SET, $eol = PHP_EOL) |
45
|
|
|
{ |
46
|
1 |
|
throw new NotYetImplementedException("This method not yet implemented."); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Assert that this file/stream object is readable. |
51
|
|
|
* |
52
|
|
|
* @return void |
53
|
|
|
* @throws CSVelte\Exception\IOException if stream isn't readable |
54
|
|
|
*/ |
55
|
10 |
|
protected function assertIsSeekable() |
56
|
|
|
{ |
57
|
10 |
|
if (!$this->isSeekable()) { |
58
|
2 |
|
throw new IOException("Stream not seekable", IOException::ERR_NOT_SEEKABLE); |
59
|
|
|
} |
60
|
9 |
|
} |
61
|
|
|
|
62
|
|
|
abstract public function isSeekable(); |
63
|
|
|
|
64
|
|
|
abstract public function seek($offset, $whence = SEEK_SET); |
65
|
|
|
|
66
|
|
|
} |
67
|
|
|
|