Ublaboo\DataGrid\Utils\ArraysHelper::testTruthy PHP Method

testTruthy() public static method

Is array and its values truthy?
public static testTruthy ( array | Traversable $a ) : boolean
$a array | Traversable
return boolean
    public static function testTruthy($a)
    {
        foreach ($a as $value) {
            if (is_array($value) || $value instanceof \Traversable) {
                if (self::testTruthy($value)) {
                    return TRUE;
                }
            } else {
                if ($value !== '' && $value !== NULL) {
                    return TRUE;
                }
            }
        }
        return FALSE;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Is filter active?
  * @return boolean
  */
 public function isFilterActive()
 {
     $is_filter = ArraysHelper::testTruthy($this->filter);
     return $is_filter || $this->force_filter_active;
 }