Improve Neuron and allow use to clone another object.
This commit is contained in:
parent
7d3d1615d5
commit
1bde430251
@ -19,20 +19,14 @@
|
|||||||
namespace Libs;
|
namespace Libs;
|
||||||
|
|
||||||
class Neuron {
|
class Neuron {
|
||||||
|
public function __construct(array|object $data = []) {
|
||||||
private $data;
|
foreach($data as $key => $value)
|
||||||
|
$this->{$key} = $value;
|
||||||
public function __construct($data = []){
|
|
||||||
$this->data = (array) $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __isset($index) {
|
public function __get(string $index) {
|
||||||
return isset($this->data[$index]);
|
return (isset($this->{$index}) &&
|
||||||
}
|
$this->{$index} != '') ? $this->{$index} : null;
|
||||||
|
|
||||||
public function __get($index){
|
|
||||||
return (isset($this->data[$index]) && $this->data[$index] != '')
|
|
||||||
? $this->data[$index] : null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user