Nestable\Tests\TestCase::_helper_recursive PHP Method

_helper_recursive() protected method

protected _helper_recursive ( array $nested, $parent_id, $total )
$nested array
    protected function _helper_recursive(array $nested, $parent_id, $total = 0)
    {
        foreach ($nested as $key => $category) {
            if (isset($category['parent_id']) && (int) $category['parent_id'] == (int) $parent_id) {
                ++$total;
            } else {
                if (isset($category['child']) && count($category['child']) > 0) {
                    $total += $this->_helper_recursive($category['child'], $parent_id, $total);
                }
            }
        }
        return $total;
    }