1 | <?php |
||
33 | class CSVelte |
||
34 | { |
||
35 | /** |
||
36 | * CSVelte\Reader Factory. |
||
37 | * |
||
38 | * Factory method for creating a new CSVelte\Reader object |
||
39 | * Used to create a local file CSV reader object. |
||
40 | * |
||
41 | * @param string $filename The filename to read |
||
42 | * @param Flavor|array|null $flavor An explicit flavor object that will be |
||
43 | * passed to the reader or an array of flavor attributes to override the |
||
44 | * default flavor attributes |
||
45 | * |
||
46 | * @throws IOException |
||
47 | * |
||
48 | * @return \CSVelte\Reader An iterator for specified CSV file |
||
49 | */ |
||
50 | 6 | public static function reader($filename, $flavor = null) |
|
57 | |||
58 | /** |
||
59 | * String Reader Factory. |
||
60 | * |
||
61 | * Factory method for creating a new CSVelte\Reader object for reading |
||
62 | * from a PHP string |
||
63 | * |
||
64 | * @param string $str The CSV data to read |
||
65 | * @param Flavor|array|null $flavor An explicit flavor object that will be |
||
66 | * passed to the reader or an array of flavor attributes to override the |
||
67 | * default flavor attributes |
||
68 | * |
||
69 | * @return Reader An iterator for provided CSV data |
||
70 | */ |
||
71 | 1 | public static function stringReader($str, $flavor = null) |
|
75 | |||
76 | /** |
||
77 | * CSVelte\Writer Factory. |
||
78 | * |
||
79 | * Factory method for creating a new CSVelte\Writer object for writing |
||
80 | * CSV data to a file. If file doesn't exist, it will be created. If it |
||
81 | * already contains data, it will be overwritten. |
||
82 | * |
||
83 | * @param string $filename The filename to write to. |
||
84 | * @param Flavor|array|null $flavor An explicit flavor object that will be |
||
85 | * passed to the reader or an array of flavor attributes to override the |
||
86 | * default flavor attributes |
||
87 | * |
||
88 | * @return Writer A writer object for writing to given filename |
||
89 | */ |
||
90 | 2 | public static function writer($filename, $flavor = null) |
|
96 | |||
97 | /** |
||
98 | * Export CSV data to local file. |
||
99 | * |
||
100 | * Facade method for exporting data to given filename. IF file doesn't exist |
||
101 | * it will be created. If it does exist it will be overwritten. |
||
102 | * |
||
103 | * @param string $filename The filename to export data to |
||
104 | * @param Iterator|array $data Data to write to CSV file |
||
105 | * @param Flavor|array|null $flavor An explicit flavor object that will be |
||
106 | * passed to the reader or an array of flavor attributes to override the |
||
107 | * default flavor attributes |
||
108 | * |
||
109 | * @return int Number of rows written |
||
110 | */ |
||
111 | 2 | public static function export($filename, $data, $flavor = null) |
|
118 | |||
119 | /** |
||
120 | * Assert that file is readable. |
||
121 | * |
||
122 | * Assert that a particular file exists and is readable (user has permission |
||
123 | * to read/access it) |
||
124 | * |
||
125 | * @param string $filename The name of the file you wish to check |
||
126 | * |
||
127 | * @throws IOException |
||
128 | * |
||
129 | * @internal |
||
130 | */ |
||
131 | 6 | protected static function assertFileIsReadable($filename) |
|
138 | |||
139 | /** |
||
140 | * Assert that a particular file exists. |
||
141 | * |
||
142 | * @param string $filename The name of the file you wish to check |
||
143 | * |
||
144 | * @throws IOException |
||
145 | * |
||
146 | * @internal |
||
147 | */ |
||
148 | 6 | protected static function assertFileExists($filename) |
|
154 | } |
||
155 |