filters = []; } /** * @return IteratorFilter */ public static function getInstance() { return new IteratorFilter(); } /** * @param array $array * @return Row[] */ public function match($array) { $returnArray = []; foreach ($array as $sr) { if ($this->evalString($sr)) { $returnArray[] = $sr; } } return $returnArray; } /** * Get the filter * * @param IteratorFilterFormatter $formatter * @param string $tableName * @param array $params * @param string $returnFields * @return string */ public function format(IteratorFilterFormatter $formatter, $tableName = null, &$params = [], $returnFields = "*") { return $formatter->format($this->filters, $tableName, $params, $returnFields); } /** * @param Row $singleRow * @return bool */ private function evalString(Row $singleRow) { $result = []; $finalResult = false; $pos = 0; $result[0] = true; foreach ($this->filters as $filter) { if (($filter[0] == ")") || ($filter[0] == " or ")) { $finalResult = $finalResult || $result[$pos]; $result[++$pos] = true; } $name = $filter[1]; $relation = $filter[2]; $value = $filter[3]; $field = [$singleRow->get($name)]; foreach ($field as $valueparam) { switch ($relation) { case Relation::EQUAL: $result[$pos] = $result[$pos] && ($valueparam == $value); break; case Relation::GREATER_THAN: $result[$pos] = $result[$pos] && ($valueparam > $value); break; case Relation::LESS_THAN: $result[$pos] = $result[$pos] && ($valueparam < $value); break; case Relation::GREATER_OR_EQUAL_THAN: $result[$pos] = $result[$pos] && ($valueparam >= $value); break; case Relation::LESS_OR_EQUAL_THAN: $result[$pos] = $result[$pos] && ($valueparam <= $value); break; case Relation::NOT_EQUAL: $result[$pos] = $result[$pos] && ($valueparam != $value); break; case Relation::STARTS_WITH: $result[$pos] = $result[$pos] && (strpos(is_null($valueparam) ? "" : $valueparam, $value) === 0); break; default: // Relation::CONTAINS: $result[$pos] = $result[$pos] && (strpos(is_null($valueparam) ? "" : $valueparam, $value) !== false); break; } } } $finalResult = $finalResult || $result[$pos]; return $finalResult; } /** * @param string $name Field name * @param int $relation Relation enum * @param string $value Field string value * @return IteratorFilter * @desc Add a single string comparison to filter. */ public function addRelation($name, $relation, $value) { $this->filters[] = [" and ", $name, $relation, $value]; return $this; } /** * @param string $name Field name * @param int $relation Relation enum * @param string $value Field string value * @return IteratorFilter * @desc Add a single string comparison to filter. This comparison use the OR operator. */ public function addRelationOr($name, $relation, $value) { $this->filters[] = [" or ", $name, $relation, $value]; return $this; } /** * Add a "(" * @return IteratorFilter */ public function startGroup() { $this->filters[] = ["(", "", "", ""]; return $this; } /** * Add a ")" * @return IteratorFilter */ public function endGroup() { $this->filters[] = [")", "", "", ""]; return $this; } /** * @return array */ public function getRawFilters() { return $this->filters; } } __halt_compiler();----SIGNATURE:----pujzerkPTX+Ma+UtT16o8C9SqTQVsIgucYbLbjcw7I4VTkwf90cqk67Im5L9hWwau9SYeoCom2265WdIj230U4jfUUvJ+WHB7dF61r05XCVPNKbEUHJkeCee7kaBgdEFQO8L6hgGmTA9T6U6BbGxC49WUCtL/q7EtSQipTH9lAHir1wSegQUs1OnIFNV8FgGNKUL2rMImw79tQU9L8Z1r3g+SUqH5/u6wOoN0JQQnIZpLowCA7fF3rrytYB2GjHYCCL/scMGtBVDJNSPhMcFvJ6uakAljrI9woTQ67CvKQcsZosC4Pw6E/IePiBCG8PMFV4FitNvcglxMCZQ0ySQg1r6/ikniPblFNYinky9oe8cbG5rW77CKcLAG+LgUOo4g82mK2afak9FRSxyI5VyFk/XPMruDp7X9SEzCWNeCvWKjuLfcDdh2L/nmUmbJ6TXmWDYvE8zClB9bzRLH8DSuaDma2b6DcWmYF3jBMMf6RmdhJ6fOQkmdrUAPzXgOMBLfvQmy92SFt21nAFwxVrXsYDG0AikWbtQ1jLNUkz5I0be5UXtEU2+1q3qB4STIjHv6AEeTARkf+dISG1vUwZ6hNclG+L1WYvlxR0La2XXFmLVWOm2g42ces7pCvT6NFJO+gkv7mN+9+zPKzVg8Nl0iHonQ8GTzhnLsZzkAPrDzyI=----ATTACHMENT:----NDk5OTEyMzc0OTk4Mjc4NSA1MTk1MTQ1MjIyNzcxMjI1IDE2ODk5OTI5NTU5MDcxODU=