@@ -34,15 +34,23 @@ public function apply(
3434
3535 /** @param array<string, mixed> $token */
3636 public function buildConditionFromToken (array $ token , bool $ htmlMode ):string {
37- $ attribute = (string )$ token ["content " ];
38- if ($ htmlMode ) {
39- $ attribute = strtolower ($ attribute );
40- }
41-
42- $ detail = $ token ["detail " ] ?? null ;
43- $ detailType = $ detail [0 ] ?? null ;
44- $ detailValue = $ detail [1 ] ?? null ;
37+ $ parts = $ this ->extractTokenParts ($ token , $ htmlMode );
38+ return $ this ->buildConditionFromParts (
39+ $ parts ["attribute " ],
40+ $ parts ["detailType " ],
41+ $ parts ["detailValue " ],
42+ );
43+ }
4544
45+ /**
46+ * @param array<string, mixed>|null $detailType
47+ * @param array<string, mixed>|null $detailValue
48+ */
49+ private function buildConditionFromParts (
50+ string $ attribute ,
51+ ?array $ detailType ,
52+ ?array $ detailValue ,
53+ ):string {
4654 if (!$ this ->hasEqualsType ($ detailType )) {
4755 return "@ {$ attribute }" ;
4856 }
@@ -52,6 +60,28 @@ public function buildConditionFromToken(array $token, bool $htmlMode):string {
5260 return $ this ->buildCondition ($ attribute , $ valueString , $ equalsType );
5361 }
5462
63+ /**
64+ * @param array<string, mixed> $token
65+ * @return array{
66+ * attribute: string,
67+ * detailType: array<string, mixed>|null,
68+ * detailValue: array<string, mixed>|null
69+ * }
70+ */
71+ private function extractTokenParts (array $ token , bool $ htmlMode ):array {
72+ $ attribute = (string )$ token ["content " ];
73+ if ($ htmlMode ) {
74+ $ attribute = strtolower ($ attribute );
75+ }
76+
77+ $ detail = $ token ["detail " ] ?? null ;
78+ return [
79+ "attribute " => $ attribute ,
80+ "detailType " => $ detail [0 ] ?? null ,
81+ "detailValue " => $ detail [1 ] ?? null ,
82+ ];
83+ }
84+
5585 /** @param array<string, mixed>|null $detailType */
5686 private function hasEqualsType (?array $ detailType ):bool {
5787 return isset ($ detailType ["type " ])
0 commit comments