Improve Neuron and allow use to clone another object.

This commit is contained in:
kj 2023-03-15 22:16:05 -04:00
parent 7d3d1615d5
commit 1bde430251

View File

@ -19,20 +19,14 @@
namespace Libs;
class Neuron {
private $data;
public function __construct($data = []){
$this->data = (array) $data;
public function __construct(array|object $data = []) {
foreach($data as $key => $value)
$this->{$key} = $value;
}
public function __isset($index) {
return isset($this->data[$index]);
}
public function __get($index){
return (isset($this->data[$index]) && $this->data[$index] != '')
? $this->data[$index] : null;
public function __get(string $index) {
return (isset($this->{$index}) &&
$this->{$index} != '') ? $this->{$index} : null;
}
}