@@ -40,7 +40,7 @@ public function process(array $data): array
4040 } else {
4141 $ categoryItem = [
4242 'id ' => $ item ['id ' ],
43- 'name ' => $ this ->normalizeName (( string ) $ item ['name ' ]),
43+ 'name ' => $ this ->normalizeName ($ item ['name ' ]),
4444 'parent ' => $ item ['parent_id ' ],
4545 ];
4646 }
@@ -69,10 +69,14 @@ public function sqlBuilder(
6969 array $ wheres = [],
7070 ?string $ orderCol = null ,
7171 ): string {
72- return 'SELECT `id`, ` ' . $ primaryCol . '`, ` ' . $ parentCol . '` '
73- . 'FROM ` ' . $ table . '` '
74- . ($ wheres !== [] ? 'WHERE ( ' . implode (') AND ( ' , $ wheres ) . ') ' : '' )
75- . 'ORDER BY ` ' . ($ orderCol ?? $ primaryCol ) . '` ASC ' ;
72+ return sprintf (
73+ 'SELECT `id`, `%s`, `%s` FROM `%s` %s ORDER BY `%s` ASC ' ,
74+ $ primaryCol ,
75+ $ parentCol ,
76+ $ table ,
77+ $ wheres !== [] ? 'WHERE ( ' . implode (') AND ( ' , $ wheres ) . ') ' : '' ,
78+ $ orderCol ?? $ primaryCol ,
79+ );
7680 }
7781
7882
@@ -81,7 +85,7 @@ public function setMaxDepth(int $maxDepth): void
8185 if ($ maxDepth < 1 ) {
8286 $ maxDepth = 1 ;
8387 } elseif ($ maxDepth > 1_000 ) {
84- throw new \InvalidArgumentException ('Max depth " ' . $ maxDepth . ' " is too big. Maximum value is 1000. ' );
88+ throw new \InvalidArgumentException (sprintf ( 'Max depth "%d " is too big. Maximum value is 1000. ' , $ maxDepth ) );
8589 }
8690 $ this ->maxDepth = $ maxDepth ;
8791 }
@@ -118,7 +122,7 @@ private function serializeCategoriesToSelectbox(
118122 if ($ category ['parent ' ] === $ parent ) {
119123 if (isset ($ usedIds [$ category ['id ' ]]) === false ) {
120124 $ return [$ category ['id ' ]] = [
121- 'name ' => $ this ->normalizeName (( string ) $ category ['name ' ]),
125+ 'name ' => $ this ->normalizeName ($ category ['name ' ]),
122126 'level ' => $ level ,
123127 ];
124128 unset($ categories [$ catKey ]);
@@ -137,7 +141,7 @@ private function serializeCategoriesToSelectbox(
137141
138142 private function normalizeName (string $ name ): string
139143 {
140- if (str_starts_with ( $ name , ' T:{ ' ) && class_exists ( ' Baraja\Localization\Translation ' )) {
144+ if (class_exists ( ' Baraja\Localization\Translation ' ) && str_starts_with ( $ name , ' T:{ ' )) {
141145 return (string ) (new Translation ($ name ));
142146 }
143147
0 commit comments