<?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 LessLessEqualsDateMethod extends AbstractDateMethod
{
  public function __construct(string $method0, string $method1)
  {
    parent::__construct(static function(ISQLFilter $filter, $value) use ($method0, $method1): ISQLFilter {
      $filter->all(static function($filter) use ($method0, $method1, $value) {
        $filter->notAll(static function($filter) use ($method0, $method1) {
          call_user_func(array($filter, 'equals' . $method0), null);
          call_user_func(array($filter, 'equals' . $method1), null);

          return $filter;
        });

        $filter->any(static function($filter) use ($method0, $method1, $value) {
          $filter->any(static function($filter) use ($method0, $value) {
            call_user_func(array($filter, 'equals' . $method0), null);
            call_user_func(array($filter, 'lessEquals' . $method0), $value);
          });

          $filter->any(static function($filter) use ($method1, $value) {
            call_user_func(array($filter, 'equals' . $method1), null);
            call_user_func(array($filter, 'lessEquals' . $method1), $value);
          });
        });

        return $filter;
      });

      return $filter;
    });
  }
}