From 32843e50aa981f190bdb4fbc9adbeacc06fdf775 Mon Sep 17 00:00:00 2001 From: polo Date: Sat, 17 Oct 2026 23:47:31 +0200 Subject: =?UTF-8?q?retypage=20date=20prestations=20en=20string=203,=20clas?= =?UTF-8?q?se=20Dates=20supprim=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Latex.php | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'src/Latex.php') diff --git a/src/Latex.php b/src/Latex.php index 261d35e..f49fdea 100644 --- a/src/Latex.php +++ b/src/Latex.php @@ -12,7 +12,7 @@ abstract class Latex protected array $data = []; // données à insérer dans le template protected string $latex; // latex pur - static function makeInstance(string $type) + static function makeInstance(string $type): ?Latex { switch($type) { @@ -38,6 +38,7 @@ abstract class Latex // erreur default: echo "erreur, la sous-classe latex à initialiser n'existe pas\n"; + return null; } } @@ -98,34 +99,23 @@ abstract class Latex abstract class PrestaLatex extends Latex { - protected Dates $Date; + protected array $date_array; // [année, mois, jour] - public function setData(Object $Object): self + 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') { $this->file_name = $Object->getCodePresta() . '.tex'; - $this->makeDateInstance($Object->getDate()); // paramètre = int - - $this->latex_path = Config::$latex_path . $this->Date->getYear() . '/'; - $this->pdf_path = Config::$pdf_path . $this->Date->getYear() . '/'; + $this->date_array = explode('-', $Object->getdate()); + $this->latex_path = Config::$latex_path . $this->date_array[0] . '/'; + $this->pdf_path = Config::$pdf_path . $this->date_array[0] . '/'; } return $this; // pour chainer les méthodes } - //~ public function getYear(): string // parce que Dates::getDate() retourne une chaine - //~ { - //~ return $this->year; - //~ } - - protected function makeDateInstance(int $timestamp) - { - $this->Date = new Dates($timestamp); - } - // forme = code-presta.tex //~ protected function nameTheFile(string $quoi, string $codePresta) //~ { @@ -135,7 +125,7 @@ abstract class PrestaLatex extends Latex public function makeLatex() { $data = $this->data; - $date = preg_replace('#\D#', '/', $this->Date->getDate()); // date avec des slashs / parce que j'aime bien + $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 // on obtient la variable $latex avec ob_get_clean() // le include() ici, c'est du génie ou c'est moche ou les deux? -- cgit v1.2.3