<commit_before><?php

/**
 * This file is part of the Nextras\ORM library.
 *
 * @license    MIT
 * @link       https://github.com/nextras/orm
 * @author     <NAME>
 */

namespace Nextras\Orm\Collection\Helpers;

use Closure;
use Nextras\Orm\Collection\ICollection;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\NotSupportedException;
use Nextras\Orm\Relationships\IRelationshipCollection;


class ArrayCollectionClosureHelper
{

	/**
	 * @param  string $condition
	 * @param  mixed  $value
	 * @return Closure
	 */
	public static function createFilter($condition, $value)
	{
		list($chain, $operator) = ConditionParserHelper::parseCondition($condition);

		if ($operator === ConditionParserHelper::OPERATOR_EQUAL) {
			if (is_array($value)) {
				$predicate = function($property) use ($value) {
					return in_array($property, $value, TRUE);
				};
			} else {
				$predicate = function($property) use ($value) {
					return $property === $value;
				};
			}
		} elseif ($operator === ConditionParserHelper::OPERATOR_NOT_EQUAL) {
			if (is_array($value)) {
				$predicate = function($property) use ($value) {
					return !in_array($property, $value, TRUE);
				};
			} else {
				$predicate = function($property) use ($value) {
					return $property !== $value;
				};
			}
		} else {<commit_msg>collection: implemented all operators for arrayCollection<commit_after><?php

/**
 * This file is part of the Nextras\ORM library.
 *
 * @license    MIT
 * @link       https://github.com/nextras/orm
 * @author     <NAME>
 */

namespace Nextras\Orm\Collection\Helpers;

use Closure;
use Nextras\Orm\Collection\ICollection;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\NotSupportedException;
use Nextras\Orm\Relationships\IRelationshipCollection;


class ArrayCollectionClosureHelper
{

	/**
	 * @param  string $condition
	 * @param  mixed  $value
	 * @return Closure
	 */
	public static function createFilter($condition, $value)
	{
		list($chain, $operator) = ConditionParserHelper::parseCondition($condition);

		if ($operator === ConditionParserHelper::OPERATOR_EQUAL) {
			if (is_array($value)) {
				$predicate = function($property) use ($value) {
					return in_array($property, $value, TRUE);
				};
			} else {
				$predicate = function($property) use ($value) {
					return $property === $value;
				};
			}
		} elseif ($operator === ConditionParserHelper::OPERATOR_NOT_EQUAL) {
			if (is_array($value)) {
				$predicate = function($property) use ($value) {
					return !in_array($property, $value, TRUE);
				};
			} else {
				$predicate = function($property) use ($value) {
					return $property !== $value;
				};
			}
		} elseif ($operator === ConditionParserHelper::OPERATOR_GREATER) {
			$predicate = function($property) use ($value) {
				return $property > $value;
			};
		} elseif ($operator === ConditionParserHelper::OPERATOR_EQUAL_OR_GREATER) {
			$predicate = function($property) use ($value) {
				return $property >= $value;
			};
		} elseif ($operator === ConditionParserHelper::OPERATOR_SMALLER) {
			$predicate = function($property) use ($value) {
				return $property < $value;
			};
		} elseif ($operator === ConditionParserHelper::OPERATOR_EQUAL_OR_SMALLER) {
			$predicate = function($property) use ($value) {
				return $property <= $value;
			};
		} else {
{'fraction_non_alphanumeric': 0.14519002375296913, 'fraction_numerical': 0.0, 'mean_word_length': 3.9690265486725664, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1367933', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1039, 'n_words': 225}