Skip to content

Commit c974c2c

Browse files
authored
Bool input fix (#30)
1 parent d4c2c04 commit c974c2c

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/CategorizedValues.php

+19-11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Asseco\JsonQueryBuilder;
66

77
use Asseco\JsonQueryBuilder\Config\TypesConfig;
8+
use Asseco\JsonQueryBuilder\Types\AbstractType;
89

910
class CategorizedValues
1011
{
@@ -25,6 +26,8 @@ class CategorizedValues
2526
public bool $null = false;
2627
public bool $notNull = false;
2728

29+
protected AbstractType $type;
30+
2831
/**
2932
* CategorizedValues constructor.
3033
* @param SearchParser $searchParser
@@ -34,17 +37,10 @@ public function __construct(SearchParser $searchParser)
3437
{
3538
$this->searchParser = $searchParser;
3639

37-
$this->prepare();
38-
$this->categorize();
39-
}
40+
$this->type = (new TypesConfig())->getTypeClassFromTypeName($this->searchParser->type);
4041

41-
/**
42-
* @throws Exceptions\JsonQueryBuilderException
43-
*/
44-
public function prepare()
45-
{
46-
$type = (new TypesConfig())->getTypeClassFromTypeName($this->searchParser->type);
47-
$this->searchParser->values = $type->prepare($this->searchParser->values);
42+
$this->categorize();
43+
$this->format();
4844
}
4945

5046
public function categorize()
@@ -83,7 +79,19 @@ public function categorize()
8379
}
8480
}
8581

86-
protected function isNegated(string $splitValue): bool
82+
/**
83+
* Format categorized values. It must be done after categorizing
84+
* because of micro operators.
85+
*/
86+
public function format()
87+
{
88+
$this->and = $this->type->prepare($this->and);
89+
$this->andLike = $this->type->prepare($this->andLike);
90+
$this->not = $this->type->prepare($this->not);
91+
$this->notLike = $this->type->prepare($this->notLike);
92+
}
93+
94+
protected function isNegated($splitValue): bool
8795
{
8896
return substr($splitValue, 0, 1) === self::NOT;
8997
}

0 commit comments

Comments
 (0)