From b7e0085fd7e4c60b9e4a4cf88bea6de30dde9c79 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Wed, 2 Oct 2024 16:09:30 +0400 Subject: [PATCH] modifs.mineures sans commentaires --- src/file/csv/AbstractReader.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/file/csv/AbstractReader.php b/src/file/csv/AbstractReader.php index 8f502b9..c30440c 100644 --- a/src/file/csv/AbstractReader.php +++ b/src/file/csv/AbstractReader.php @@ -10,6 +10,9 @@ abstract class AbstractReader implements IReader { const HEADERS = null; + /** @var bool faut-il utiliser les en-tĂȘtes pour retourner des tableaux associatifs? */ + const USE_HEADERS = true; + /** @var ?string nom du fichier depuis lequel lire */ const INPUT = null; @@ -37,6 +40,7 @@ abstract class AbstractReader implements IReader { # $this->schema = $params["schema"] ?? static::SCHEMA; $this->headers = $params["headers"] ?? static::HEADERS; + $this->useHeaders = $params["use_headers"] ?? static::USE_HEADERS; $this->input = $params["input"] ?? static::INPUT; $this->trim = boolval($params["trim"] ?? static::TRIM); $this->parseEmptyAsNull = boolval($params["empty_as_null"] ?? static::PARSE_EMPTY_AS_NULL); @@ -48,6 +52,8 @@ abstract class AbstractReader implements IReader { protected ?array $headers; + protected bool $useHeaders; + protected $input; protected bool $trim; @@ -61,6 +67,7 @@ abstract class AbstractReader implements IReader { protected int $isrc = 0, $idest = 0; protected function cook(array &$row): bool { + if (!$this->useHeaders) return true; if ($this->isrc == 0) { # ligne d'en-tĂȘte $headers = $this->headers;