@@ -45,7 +45,9 @@ |
||
| 45 | 45 | { |
| 46 | 46 | $size = 0; |
| 47 | 47 | $buffer = false; |
| 48 | - if (!is_array($eol)) $eol = array($eol); |
|
| 48 | + if (!is_array($eol)) { |
|
| 49 | + $eol = array($eol); |
|
| 50 | + } |
|
| 49 | 51 | while (!$this->eof()) { |
| 50 | 52 | // Using a loose equality here to match on '' and false. |
| 51 | 53 | if (null == ($byte = $this->read(1))) { |
@@ -91,8 +91,8 @@ |
||
| 91 | 91 | public function __construct($input, $flavor = null) |
| 92 | 92 | { |
| 93 | 93 | $this->setSource($input) |
| 94 | - ->setFlavor($flavor) |
|
| 95 | - ->rewind(); |
|
| 94 | + ->setFlavor($flavor) |
|
| 95 | + ->rewind(); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -104,7 +104,9 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | protected function setFlavor($flavor = null) |
| 106 | 106 | { |
| 107 | - if (is_array($flavor)) $flavor = new Flavor($flavor); |
|
| 107 | + if (is_array($flavor)) { |
|
| 108 | + $flavor = new Flavor($flavor); |
|
| 109 | + } |
|
| 108 | 110 | $taster = new Taster($this->source); |
| 109 | 111 | // @todo put this inside a try/catch |
| 110 | 112 | if (is_null($flavor)) { |
@@ -159,7 +161,9 @@ discard block |
||
| 159 | 161 | $this->header = new HeaderRow($parsed); |
| 160 | 162 | } else { |
| 161 | 163 | $this->current = new Row($parsed); |
| 162 | - if ($this->header) $this->current->setHeaderRow($this->header); |
|
| 164 | + if ($this->header) { |
|
| 165 | + $this->current->setHeaderRow($this->header); |
|
| 166 | + } |
|
| 163 | 167 | } |
| 164 | 168 | } catch (EndOfFileException $e) { |
| 165 | 169 | $this->current = false; |
@@ -183,7 +187,9 @@ discard block |
||
| 183 | 187 | $eol = $f->lineTerminator; |
| 184 | 188 | try { |
| 185 | 189 | do { |
| 186 | - if (!isset($lines)) $lines = array(); |
|
| 190 | + if (!isset($lines)) { |
|
| 191 | + $lines = array(); |
|
| 192 | + } |
|
| 187 | 193 | if (false === ($line = $this->source->readLine($eol))) { |
| 188 | 194 | throw new EndOfFileException("End of file reached: " . $this->source->getName()); |
| 189 | 195 | } |
@@ -191,7 +197,9 @@ discard block |
||
| 191 | 197 | } while ($this->inQuotedString(end($lines), $f->quoteChar, $f->escapeChar)); |
| 192 | 198 | } catch (EndOfFileException $e) { |
| 193 | 199 | // only throw the exception if we don't already have lines in the buffer |
| 194 | - if (!count($lines)) throw $e; |
|
| 200 | + if (!count($lines)) { |
|
| 201 | + throw $e; |
|
| 202 | + } |
|
| 195 | 203 | } |
| 196 | 204 | return rtrim(implode($eol, $lines), $eol); |
| 197 | 205 | } |
@@ -211,14 +219,18 @@ discard block |
||
| 211 | 219 | { |
| 212 | 220 | if (!empty($line)) { |
| 213 | 221 | do { |
| 214 | - if (!isset($i)) $i = 0; |
|
| 222 | + if (!isset($i)) { |
|
| 223 | + $i = 0; |
|
| 224 | + } |
|
| 215 | 225 | $c = $line[$i++]; |
| 216 | 226 | if ($this->escape) { |
| 217 | 227 | $this->escape = false; |
| 218 | 228 | continue; |
| 219 | 229 | } |
| 220 | 230 | $this->escape = ($c == $escapeChar); |
| 221 | - if ($c == $quoteChar) $this->open = !$this->open; |
|
| 231 | + if ($c == $quoteChar) { |
|
| 232 | + $this->open = !$this->open; |
|
| 233 | + } |
|
| 222 | 234 | } while ($i < strlen($line)); |
| 223 | 235 | } |
| 224 | 236 | return $this->open; |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | protected function replaceQuotedSpecialChars($data, $delim, $quo, $eol) |
| 285 | 285 | { |
| 286 | - return preg_replace_callback('/(['. preg_quote($quo, '/') . '])(.*)\1/imsU', function($matches) use ($delim, $eol) { |
|
| 286 | + return preg_replace_callback('/(['.preg_quote($quo, '/').'])(.*)\1/imsU', function($matches) use ($delim, $eol) { |
|
| 287 | 287 | $ret = str_replace($eol, self::PLACEHOLDER_NEWLINE, $matches[0]); |
| 288 | 288 | $ret = str_replace($delim, self::PLACEHOLDER_DELIM, $ret); |
| 289 | 289 | return $ret; |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | protected function unEscape($str, $esc, $quo) |
| 337 | 337 | { |
| 338 | - return str_replace($esc . $quo, $quo, $str); |
|
| 338 | + return str_replace($esc.$quo, $quo, $str); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | */ |
| 477 | 477 | public function toArray() |
| 478 | 478 | { |
| 479 | - return array_map(function($row){ |
|
| 479 | + return array_map(function($row) { |
|
| 480 | 480 | return $row->toArray(); |
| 481 | 481 | }, iterator_to_array($this)); |
| 482 | 482 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | { |
| 124 | 124 | self::assertFileExists($filename); |
| 125 | 125 | if (!is_readable($filename)) { |
| 126 | - throw new IOException('Permission denied for: ' . $filename, IOException::ERR_FILE_PERMISSION_DENIED); |
|
| 126 | + throw new IOException('Permission denied for: '.$filename, IOException::ERR_FILE_PERMISSION_DENIED); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | protected static function assertFileExists($filename) |
| 138 | 138 | { |
| 139 | 139 | if (!file_exists($filename)) { |
| 140 | - throw new IOException('File does not exist: ' . $filename, IOException::ERR_FILE_NOT_FOUND); |
|
| 140 | + throw new IOException('File does not exist: '.$filename, IOException::ERR_FILE_NOT_FOUND); |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -62,10 +62,10 @@ discard block |
||
| 62 | 62 | $paths = $this->getPaths(); |
| 63 | 63 | if ($rp = realpath($path)) { |
| 64 | 64 | if (in_array($rp, $paths)) return true; |
| 65 | - $this->paths []= $rp; |
|
| 65 | + $this->paths [] = $rp; |
|
| 66 | 66 | return true; |
| 67 | 67 | } |
| 68 | - $this->paths []= $path; |
|
| 68 | + $this->paths [] = $path; |
|
| 69 | 69 | return false; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -113,14 +113,14 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function load($className) |
| 115 | 115 | { |
| 116 | - if(class_exists($className)) { |
|
| 116 | + if (class_exists($className)) { |
|
| 117 | 117 | return; |
| 118 | 118 | } |
| 119 | 119 | $fqcp = str_replace(self::NAMESPACE_SEPARATOR, DIRECTORY_SEPARATOR, $className); |
| 120 | 120 | $paths = $this->getPaths(); |
| 121 | 121 | foreach ($paths as $path) { |
| 122 | - $classPath = $path . DIRECTORY_SEPARATOR . $fqcp . '.php'; |
|
| 123 | - if(file_exists($classPath) && is_readable($classPath)) { |
|
| 122 | + $classPath = $path.DIRECTORY_SEPARATOR.$fqcp.'.php'; |
|
| 123 | + if (file_exists($classPath) && is_readable($classPath)) { |
|
| 124 | 124 | require_once($classPath); |
| 125 | 125 | return; |
| 126 | 126 | } |
@@ -61,7 +61,9 @@ |
||
| 61 | 61 | { |
| 62 | 62 | $paths = $this->getPaths(); |
| 63 | 63 | if ($rp = realpath($path)) { |
| 64 | - if (in_array($rp, $paths)) return true; |
|
| 64 | + if (in_array($rp, $paths)) { |
|
| 65 | + return true; |
|
| 66 | + } |
|
| 65 | 67 | $this->paths []= $rp; |
| 66 | 68 | return true; |
| 67 | 69 | } |
@@ -19,7 +19,6 @@ |
||
| 19 | 19 | if (if $file->hasHeader()) { |
| 20 | 20 | $header = $file->getHeader() |
| 21 | 21 | } |
| 22 | - |
|
| 23 | 22 | * you can instead simply call $header->getHeader() and handle this exception if |
| 24 | 23 | * said file has no header |
| 25 | 24 | * |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | */ |
| 41 | 41 | public function writeLine($line, $eol = PHP_EOL) |
| 42 | 42 | { |
| 43 | - return $this->write($line . $eol); |
|
| 43 | + return $this->write($line.$eol); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -91,7 +91,9 @@ |
||
| 91 | 91 | { |
| 92 | 92 | $res = (new Resource($uri, $mode)) |
| 93 | 93 | ->setContextResource($context); |
| 94 | - if (!$lazy) $res->connect(); |
|
| 94 | + if (!$lazy) { |
|
| 95 | + $res->connect(); |
|
| 96 | + } |
|
| 95 | 97 | return $res; |
| 96 | 98 | } |
| 97 | 99 | |
@@ -267,16 +267,16 @@ |
||
| 267 | 267 | return strlen($data); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - /** |
|
| 271 | - * Seekability accessor. |
|
| 272 | - * |
|
| 273 | - * Despite the fact that any class that implements this interface must also |
|
| 274 | - * define methods such as seek, that is no guarantee that an |
|
| 275 | - * object will necessarily be seekable. This method should tell the user |
|
| 276 | - * whether a stream is, in fact, seekable. |
|
| 277 | - * |
|
| 278 | - * @return boolean True if seekable, false otherwise |
|
| 279 | - */ |
|
| 270 | + /** |
|
| 271 | + * Seekability accessor. |
|
| 272 | + * |
|
| 273 | + * Despite the fact that any class that implements this interface must also |
|
| 274 | + * define methods such as seek, that is no guarantee that an |
|
| 275 | + * object will necessarily be seekable. This method should tell the user |
|
| 276 | + * whether a stream is, in fact, seekable. |
|
| 277 | + * |
|
| 278 | + * @return boolean True if seekable, false otherwise |
|
| 279 | + */ |
|
| 280 | 280 | public function isSeekable() |
| 281 | 281 | { |
| 282 | 282 | return $this->seekable; |