From 64ac1605b6fe8e997134dd57cc30f30b99ebc076 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Wed, 29 Jan 2020 02:34:50 +0100 Subject: refactor : item abstract class new Item abstract class with hydrate and dry functions to clean others --- app/class/Page.php | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'app/class/Page.php') diff --git a/app/class/Page.php b/app/class/Page.php index 170a057..82e61c1 100644 --- a/app/class/Page.php +++ b/app/class/Page.php @@ -6,7 +6,7 @@ use DateTime; use DateTimeImmutable; use DateTimeZone; -class Page +class Page extends Dbitem { protected $id; protected $title; @@ -63,17 +63,6 @@ class Page $this->hydrate($datas); } - public function hydrate($datas) - { - foreach ($datas as $key => $value) { - $method = 'set' . $key; - - if (method_exists($this, $method)) { - $this->$method($value); - } - } - } - public function reset() { $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); @@ -125,19 +114,6 @@ class Page return ['pagevarlist' => $classvarlist]; } - public function dry() - { - $array = []; - foreach (get_class_vars(__class__) as $var => $value) { - if (in_array($var, self::VAR_DATE)) { - $array[$var] = $this->$var('string'); - } else { - $array[$var] = $this->$var(); - } - } - return $array; - } - /** * Check if page have a thumbnail * @return bool true if the page have a thumbnail otherwise return false. -- cgit v1.2.3