/** * * If the element belong to connection returns this connection, in other case throw a not found exception * * @param Element $element * @return Connection */ public function belongToConnection(Element $element) { foreach ($this->elements['connections'] as $connection) { // check start element if ($connection->getStartElement()->getId() == $element->getId()) { return $connection; } // check end element if ($connection->getEndElement()->getId() == $element->getId()) { return $connection; } } return false; }