From b0f06b1d7dc3a790d6d8babe5f0855c08c5f7878 Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 20 Oct 2026 21:49:17 +0200 Subject: =?UTF-8?q?mise=20en=20place=20de=20l'h=C3=A9ritage=202,=20nombreu?= =?UTF-8?q?ses=20simplifications=20et=20factorisations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Latex.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/Latex.php') diff --git a/src/Latex.php b/src/Latex.php index c638264..871a845 100644 --- a/src/Latex.php +++ b/src/Latex.php @@ -14,8 +14,7 @@ abstract class Latex static function makeInstance(string $type): ?Latex { - switch($type) - { + switch($type){ // documents pour les clients case 'devis': return new DevisLatex; @@ -120,9 +119,10 @@ abstract class Latex //~ $this->pdf_path = $pdf_path; //~ } - public function setData(Object $Object) + public function setData(Object $Object): Latex { $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs + return $this; // pour chainer les méthodes } } @@ -134,9 +134,11 @@ abstract class PrestaLatex extends Latex public function setData(Object $Object): Latex // polymorphisme { $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs - - if(get_class($Object) === 'Prestation') - { + if(isset($this->data['date'])){ + $this->data['date'] = str_replace('-', '/', $this->data['date']); // 17/10/2026, avec des / parce que j'aime bien + } + + if(in_array(get_class($Object), ['Facture', 'Devis', 'Location'])){ $this->file_name = $Object->getCodePresta() . '.tex'; $this->date_array = explode('-', $Object->getdate()); $this->latex_path = Config::$latex_path . $this->date_array[0] . DIRECTORY_SEPARATOR; @@ -152,10 +154,10 @@ abstract class PrestaLatex extends Latex //~ $this->fileName = $quoi . '-' . $codePresta . '.tex'; //~ } - public function makeLatex() + public function makeLatex(): void { $data = $this->data; - $date = preg_replace('#\D#', '/', $this->date_array[2] . '/' . $this->date_array[1] . '/' . $this->date_array[0]); // 17/10/2026, avec des / parce que j'aime bien + //$date = preg_replace('#\D#', '/', $this->date_array[2] . '/' . $this->date_array[1] . '/' . $this->date_array[0]); // on obtient la variable $latex avec ob_get_clean() // le include() ici, c'est du génie ou c'est moche ou les deux? @@ -189,11 +191,13 @@ class EnveloppeRectoLatex extends Latex $this->pdf_path = Config::$pdf_path . 'enveloppes_recto/'; } - public function setData(Object $Client) // ici de type Clients + public function setData(Object $Client): Latex // ici de type Clients { $this->file_name = $Client->getCodeClient() . '.tex'; $this->data = array_merge($this->data, $Client->getAll()); // nécessite des tableaux associatifs $this->spacesInPostCode(); // nécessite $this->data + + return $this; // pour chainer les méthodes } // code postal avec 2 espaces entre chaque chiffre: 2 \ 9 \ 0 \ 0 \ 0 -- cgit v1.2.3