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/Opt.php | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'app/class/Opt.php') diff --git a/app/class/Opt.php b/app/class/Opt.php index cbbac02..60dfb65 100644 --- a/app/class/Opt.php +++ b/app/class/Opt.php @@ -2,7 +2,7 @@ namespace Wcms; -class Opt +class Opt extends Item { protected $sortby = 'id'; protected $order = 1; @@ -26,32 +26,8 @@ class Opt $this->hydrate($donnees); } - public function hydrate(array $donnees) - { - foreach ($donnees as $key => $value) { - $method = 'set' . $key; - if (method_exists($this, $method)) { - $this->$method($value); - } - } - } - /** - * Return any asked vars and their values of an object as associative array - * - * @param array $vars list of vars - * @return array Associative array `$var => $value` - */ - public function drylist(array $vars) : array - { - $array = []; - foreach ($vars as $var) { - if (property_exists($this, $var)) - $array[$var] = $this->$var; - } - return $array; - } public function resetall() -- cgit v1.2.3