Improve Neuron and allow use to clone another object.
This commit is contained in:
parent
7d3d1615d5
commit
1bde430251
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user