<?php
namespace Helpers\Outil;

// phpcs:ignore
class treeview
{
    
    public function __construct()
    {
    }

    /**
     * @param mixed $array
     * @return mixed
     */
    // phpcs:ignore
    public function array_filter_and_tags($array)
    {
        foreach ($array as &$value) {
            if (is_array($value)) {
                $value = $this->array_filter_and_tags($value);
                if (array_key_exists('id', $value)) {
                    if (array_key_exists('nodes', $value)) {
                        $value['tags'] = array(count($value['nodes']));
                    } else {
                        $value['tags'] = array(0);
                    }
                }
            }
        }
        
        return array_filter($array, function ($val) {
            return ($val || is_numeric($val));
        });
    }
}
