Files
2026-07-07 19:10:50 +03:00

42 lines
1.2 KiB
PHP

<?php
namespace Ixrs\Catalog\Support;
class IBlock
{
static array $operations = [
'!><' => 'NB', //not between
'!=' => 'NI', //not Identical
'!%' => 'NS', //not substring
'><' => 'B', //between
'>=' => 'GE', //greater or equal
'<=' => 'LE', //less or equal
'=' => 'I', //Identical
'%' => 'S', //substring
'?' => '?', //logical
'>' => 'G', //greater
'<' => 'L', //less
'!' => 'N', // not field LIKE val
'*' => 'FT', // partial full text match
'*=' => 'FTI', // identical full text match
'*%' => 'FTL', // partial full text match based on LIKE
];
public static function getOperationFilter($key)
{
$re = '/^(!><|!=|!%|><|>=|<=|=|%|\?|>|<|!|\*|\*=|\*%)?(PROPERTY_)(\d+)$/m';
$matches = [];
$r = preg_match($re, $key, $matches);
if($r){
return [
'FIELD' => mb_strtoupper($matches[2] . $matches[3]),
'OPERATION' => static::$operations[$matches[1]]??'',
'PREFIX' => $matches[1],
'ID' => $matches[3],
];
}
return [];
}
}