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) |
|
|
|
|
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
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.