1 | <?php |
||
28 | class Writer extends AbstractCsv |
||
29 | { |
||
30 | use RowFilter; |
||
31 | |||
32 | /** |
||
33 | * @inheritdoc |
||
34 | */ |
||
35 | protected $stream_filter_mode = STREAM_FILTER_WRITE; |
||
36 | |||
37 | /** |
||
38 | * The CSV object holder |
||
39 | * |
||
40 | * @var SplFileObject |
||
41 | */ |
||
42 | protected $csv; |
||
43 | |||
44 | /** |
||
45 | * fputcsv method from SplFileObject |
||
46 | * |
||
47 | * @var ReflectionMethod |
||
48 | */ |
||
49 | protected static $fputcsv; |
||
50 | |||
51 | /** |
||
52 | * Nb parameters for SplFileObject::fputcsv method |
||
53 | * |
||
54 | * @var integer |
||
55 | */ |
||
56 | protected static $fputcsv_param_count; |
||
57 | |||
58 | /** |
||
59 | * @inheritdoc |
||
60 | */ |
||
61 | 69 | protected function __construct($path, $open_mode = 'r+') |
|
67 | |||
68 | /** |
||
69 | * initiate a SplFileObject::fputcsv method |
||
70 | 69 | */ |
|
71 | protected static function initFputcsv() |
||
78 | |||
79 | /** |
||
80 | * Adds multiple lines to the CSV document |
||
81 | * |
||
82 | * a simple wrapper method around insertOne |
||
83 | * |
||
84 | * @param Traversable|array $rows a multidimensional array or a Traversable object |
||
85 | * |
||
86 | * @throws InvalidArgumentException If the given rows format is invalid |
||
87 | * |
||
88 | * @return static |
||
89 | 12 | */ |
|
90 | public function insertAll($rows) |
||
104 | |||
105 | /** |
||
106 | * Adds a single line to a CSV document |
||
107 | * |
||
108 | * @param string[]|string $row a string, an array or an object implementing to '__toString' method |
||
109 | * |
||
110 | * @return static |
||
111 | 39 | */ |
|
112 | public function insertOne($row) |
||
129 | 36 | ||
130 | /** |
||
131 | * returns the parameters for SplFileObject::fputcsv |
||
132 | * |
||
133 | * @param array $fields The fields to be add |
||
134 | * |
||
135 | * @return array |
||
136 | */ |
||
137 | protected function getFputcsvParameters(array $fields) |
||
146 | 36 | ||
147 | /** |
||
148 | * Adds default formatters. |
||
149 | * |
||
150 | * @return static |
||
151 | */ |
||
152 | 6 | private function addDefaultFormatters() |
|
164 | 69 | ||
165 | /** |
||
166 | * {@inheritdoc} |
||
167 | */ |
||
168 | public function isActiveStreamFilter() |
||
172 | |||
173 | /** |
||
174 | * {@inheritdoc} |
||
175 | */ |
||
176 | public function __destruct() |
||
181 | } |
||
182 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.