BpNode: add a new helper method

This commit is contained in:
Thomas Gelf 2017-01-27 15:32:08 +01:00
parent 6bb1c07461
commit 61fd8caa93

View file

@ -3,6 +3,7 @@
namespace Icinga\Module\Businessprocess;
use Icinga\Exception\ConfigurationError;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Businessprocess\Exception\NestingError;
class BpNode extends Node
@ -121,7 +122,7 @@ class BpNode extends Node
{
$problems = array();
foreach ($this->children as $child) {
foreach ($this->getChildren() as $child) {
if ($child->isProblem()
|| ($child instanceof BpNode && $child->hasProblems())
) {
@ -444,6 +445,22 @@ class BpNode extends Node
return $children;
}
/**
* @param $childName
* @return Node
* @throws NotFoundError
*/
public function getChildByName($childName)
{
foreach ($this->getChildren() as $name => $child) {
if ($name === $childName) {
return $child;
}
}
throw new NotFoundError('Trying to get missing child %s', $childName);
}
protected function assertNumericOperator()
{
if (! is_numeric($this->operator)) {