<?php
namespace nulib\php\iter;

use nulib\exceptions;

class Filter implements IFilter {
  static function with($filter): IFilter {
    if ($filter instanceof IFilter) return $filter;
    elseif (is_array($filter)) return new static($filter);
    elseif ($filter === null) return NullFilter::get();
    else throw exceptions::invalid_type($filter, "filter", IFilter::class);
  }

  function __construct(?array $filter) {
    $this->filter = $filter;
  }

  protected ?array $filter;

  function matchValue($value): bool {
    $filter = $this->filter;
    if ($filter === null) return true;
    #XXX implémenter le filtre
    return false;
  }
}
