11<?php
22
3- /*
4- * This file is part of the Monolog package.
5- *
6- * (c) Jordi Boggiano <j.boggiano@seld.be>
7- *
8- * For the full copyright and license information, please view the LICENSE
9- * file that was distributed with this source code.
10- */
11-
123namespace FemtoPixel \Monolog \Handler ;
134
5+ use Monolog \Formatter \FormatterInterface ;
6+ use Monolog \Formatter \LineFormatter ;
147use Monolog \Formatter \NormalizerFormatter ;
158use Monolog \Handler \StreamHandler ;
169
1912 *
2013 * Can be used to store big loads to physical files and import them later into another system that can handle CSV
2114 *
22- * @author Jay MOULIN <jaymoulin@gmail .com>
15+ * @author Jay MOULIN <jay@femtopixel .com>
2316 */
2417class CsvHandler extends StreamHandler
2518{
@@ -30,7 +23,7 @@ class CsvHandler extends StreamHandler
3023 /**
3124 * @inheritdoc
3225 */
33- protected function streamWrite ($ resource , array $ record )
26+ protected function streamWrite ($ stream , array $ record ): void
3427 {
3528 if (is_array ($ record ['formatted ' ])) {
3629 foreach ($ record ['formatted ' ] as $ key => $ info ) {
@@ -39,17 +32,20 @@ protected function streamWrite($resource, array $record)
3932 }
4033 }
4134 }
42- $ formated = (array )$ record ['formatted ' ];
35+ $ formatted = (array )$ record ['formatted ' ];
4336 if (version_compare (PHP_VERSION , '5.5.4 ' , '>= ' ) && !defined ('HHVM_VERSION ' )) {
44- return fputcsv ($ resource , $ formated , static ::DELIMITER , static ::ENCLOSURE , static ::ESCAPE_CHAR );
37+ fputcsv ($ stream , $ formatted , static ::DELIMITER , static ::ENCLOSURE , static ::ESCAPE_CHAR );
38+ return ;
4539 }
46- return fputcsv ($ resource , $ formated , static ::DELIMITER , static ::ENCLOSURE );
40+ fputcsv ($ stream , $ formatted , static ::DELIMITER , static ::ENCLOSURE );
4741 }
4842
4943 /**
50- * @inheritdoc
44+ * Gets the default formatter.
45+ *
46+ * Overwrite this if the LineFormatter is not a good default for your handler.
5147 */
52- protected function getDefaultFormatter ()
48+ protected function getDefaultFormatter (): FormatterInterface
5349 {
5450 return new NormalizerFormatter ();
5551 }
0 commit comments