public function addChild($c) { if ($c instanceof Child) { $this->childNodes[] = $c; } else { if (is_array($c)) { $this->childNodes[] = Child::factory($c); } else { throw new Exception('The argument passed is not valid.'); } } return $this; }