5
5
namespace Asseco \JsonQueryBuilder ;
6
6
7
7
use Asseco \JsonQueryBuilder \Config \TypesConfig ;
8
+ use Asseco \JsonQueryBuilder \Types \AbstractType ;
8
9
9
10
class CategorizedValues
10
11
{
@@ -25,6 +26,8 @@ class CategorizedValues
25
26
public bool $ null = false ;
26
27
public bool $ notNull = false ;
27
28
29
+ protected AbstractType $ type ;
30
+
28
31
/**
29
32
* CategorizedValues constructor.
30
33
* @param SearchParser $searchParser
@@ -34,17 +37,10 @@ public function __construct(SearchParser $searchParser)
34
37
{
35
38
$ this ->searchParser = $ searchParser ;
36
39
37
- $ this ->prepare ();
38
- $ this ->categorize ();
39
- }
40
+ $ this ->type = (new TypesConfig ())->getTypeClassFromTypeName ($ this ->searchParser ->type );
40
41
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 ();
48
44
}
49
45
50
46
public function categorize ()
@@ -83,7 +79,19 @@ public function categorize()
83
79
}
84
80
}
85
81
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
87
95
{
88
96
return substr ($ splitValue , 0 , 1 ) === self ::NOT ;
89
97
}
0 commit comments