1 | <?php |
||
24 | class ar_content_filesFile extends arBase implements ar_content_filesFileInterface { |
||
25 | |||
26 | private $resource = null; |
||
27 | |||
28 | 56 | public function __construct( $resource ) { |
|
31 | |||
32 | 56 | public function __destruct() { |
|
33 | 56 | if ($this->resource) { |
|
34 | 56 | fclose( $this->resource ); |
|
35 | 28 | } |
|
36 | 56 | } |
|
37 | |||
38 | public function read( $length ) { |
||
41 | |||
42 | 4 | public function readfile() { |
|
45 | |||
46 | 52 | public function getContents( $length = -1, $offset = -1 ) { |
|
47 | 52 | $curpos = ftell( $this->resource ); |
|
48 | 52 | $res = stream_get_contents( $this->resource, $length, $offset ); |
|
49 | 52 | fseek( $this->resource, $curpos ); |
|
50 | 52 | return $res; |
|
51 | } |
||
52 | |||
53 | public function write( $string, $length = null ) { |
||
56 | |||
57 | public function eof() { |
||
60 | |||
61 | public function size() { |
||
62 | $curpos = ftell( $this->resource ); |
||
63 | fseek( $this->resource, 0, SEEK_END ); |
||
64 | $size = ftell( $this->resource ); |
||
65 | fseek( $this->resource, $curpos ); |
||
66 | return $size; |
||
67 | } |
||
68 | |||
69 | public function getc() { |
||
72 | |||
73 | public function getcsv( $length=0, $delimiter=',', $enclosure='"', $escape='\\' ) { |
||
76 | |||
77 | public function gets( $length = null ) { |
||
80 | |||
81 | public function seek( $offset, $whence = SEEK_SET ) { |
||
84 | |||
85 | public function tell() { |
||
88 | |||
89 | public function truncate( $size ) { |
||
92 | |||
93 | public function rewind() { |
||
96 | |||
97 | protected function getResource() { |
||
98 | return $this->resource; |
||
100 | |||
101 | 12 | public function getMetaData() { |
|
104 | |||
105 | } |
||
106 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.