diff --git a/src/Query/GroupOption.php b/src/Query/GroupOption.php index d51a20c..f5fb70a 100644 --- a/src/Query/GroupOption.php +++ b/src/Query/GroupOption.php @@ -92,6 +92,10 @@ class GroupOption implements QueryOptionInterface, QueryOptionTreeItemInterface $this->{$prop}[$option->id()] = $option; return TRUE; } + // Direct child. + elseif (isset($this->childGroups[$target_id])) { + return $this->childGroups[$target_id]->insert($target_id, $option); + } elseif ($proper_child = array_reduce($this->childGroups, $find_proper_id, NULL)) { return $this->childGroups[$proper_child]->insert($target_id, $option); } @@ -143,8 +147,8 @@ class GroupOption implements QueryOptionInterface, QueryOptionTreeItemInterface return TRUE; } - // If any child GroupOptions or their children have the id return TRUE. - return array_reduce($this->groupOptions, function ($has_child, $group) use ($id) { + // If any child Groups or their children have the id return TRUE. + return array_reduce($this->childGroups, function ($has_child, $group) use ($id) { // If we already know that we have the child, skip evaluation and return. return $has_child || $group->id() == $id || $group->hasChild($id); }, FALSE); diff --git a/src/Query/QueryOptionTreeItemInterface.php b/src/Query/QueryOptionTreeItemInterface.php index 102921c..632f8af 100644 --- a/src/Query/QueryOptionTreeItemInterface.php +++ b/src/Query/QueryOptionTreeItemInterface.php @@ -21,7 +21,7 @@ interface QueryOptionTreeItemInterface { public function insert($target_id, QueryOptionInterface $option); /** - * Returns whether or the given id is a (grand)child of the object. + * Returns whether the given id is a (grand)child of the object. */ public function hasChild($id);