<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\Web\KuferTools\Utils\FilterSearch\Method;

use Kufer\Web\Classes\Dbfilter\ISQLFilter;

class NotMethod implements ISearchFilterMethod
{
  
  protected $method;

  public function __construct(ISearchFilterMethod $method)
  {
    $this->method = $method;
  }

  public function fromRequest($value)
  {
    return $this->method->fromRequest($value);
  }

  public function fromSession($value)
  {
    return $this->method->fromSession($value);
  }

  public function toSession($value)
  {
    return $this->method->toSession($value);
  }

  public function apply($filter, $value): ISQLFilter
  {
    return $filter->notAny(function(ISQLFilter $filter) use ($value): ISQLFilter {
      return $this->method->apply($filter, $value);
    });
  }
}