From eff0b8676220bf4dc95cc44e18310cc65958629b Mon Sep 17 00:00:00 2001 From: KJ Date: Sun, 4 Jun 2023 14:47:58 -0400 Subject: [PATCH] Allow construct Neuron with named arguments. Example: stringValue; // "Hello world" will be printed. ?> Also, is possible to send infinite params without names and his names will be numeric similar as a non-asociatie array, but as Neuron object. Example: {0}; // "Hello world" will be printed. ?> --- src/Libs/Neuron.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Libs/Neuron.php b/src/Libs/Neuron.php index 59678b1..c86f477 100644 --- a/src/Libs/Neuron.php +++ b/src/Libs/Neuron.php @@ -25,9 +25,15 @@ class Neuron { /** * __construct * - * @param object|array $data + * @param array $data */ - public function __construct(array|object $data = []) { + public function __construct(...$data) { + if (count($data) === 1 && + isset($data[0]) && + (is_array($data[0]) || + is_object($data[0]))) + $data = $data[0]; + foreach($data as $key => $value) $this->{$key} = $value; }