nodes[] = $this->createNode($nodeClass, $activationFunction); } } /** * @param string $nodeClass * @param ActivationFunction|null $activationFunction * * @return Neuron */ private function createNode(string $nodeClass, ActivationFunction $activationFunction = null) { if (Neuron::class == $nodeClass) { return new Neuron($activationFunction); } return new $nodeClass(); } /** * @param Node $node */ public function addNode(Node $node) { $this->nodes[] = $node; } /** * @return Node[] */ public function getNodes() { return $this->nodes; } }