@@ -31,16 +31,16 @@ class DataTable extends Orm
3131 \FloatPHP \Helpers \Framework \inc \TraitTranslatable,
3232 \FloatPHP \Helpers \Framework \inc \TraitLoggable;
3333
34- /**
35- * @access protected
36- * @var array $columns, Table columns
37- * @var array $request, Table request
38- * @var array $search, Search binded data
39- * @var array $match, Custom columns keys
40- * @var int $total, Table total
41- * @var int $filtered, Search count
42- * @var int $chars, Search length
43- */
34+ /**
35+ * @access protected
36+ * @var array $columns, Table columns
37+ * @var array $request, Table request
38+ * @var array $search, Search binded data
39+ * @var array $match, Custom columns keys
40+ * @var int $total, Table total
41+ * @var int $filtered, Search count
42+ * @var int $chars, Search length
43+ */
4444 protected $ columns = [];
4545 protected $ request = [];
4646 protected $ search = [];
@@ -97,12 +97,12 @@ protected function build(?string $table = null, ?string $key = null, array $colu
9797 {
9898 // Init ORM
9999 parent ::__construct ();
100-
100+
101101 // Set table
102- $ this ->table = ( $ table) ? $ table : (new Catcher ())->key ;
103- $ this ->key = ( $ key) ? $ key : "{$ this ->table }Id " ;
104- $ this ->columns = ( $ columns) ? $ columns : $ this ->columns ();
105-
102+ $ this ->table = $ table ? $ table : (new Catcher ())->key ;
103+ $ this ->key = $ key ? : "{$ this ->table }Id " ;
104+ $ this ->columns = $ columns ? $ columns : $ this ->columns ();
105+
106106 // Set request
107107 $ this ->request = $ this ->getRequest ();
108108
@@ -136,7 +136,7 @@ protected function preRender(array $data = []) : array
136136 * @param array $match
137137 * @return void
138138 */
139- protected function match (array $ match = [])
139+ protected function match (array $ match = []) : void
140140 {
141141 $ this ->match = $ match ;
142142 }
@@ -164,8 +164,8 @@ protected function getSearchPattern(string $search) : string
164164 */
165165 protected function getStart () : int
166166 {
167- return isset ($ this ->request ['start ' ])
168- ? intval ($ this ->request ['start ' ]) : 0 ;
167+ return isset ($ this ->request ['start ' ])
168+ ? intval ($ this ->request ['start ' ]) : 0 ;
169169 }
170170
171171 /**
@@ -176,8 +176,8 @@ protected function getStart() : int
176176 */
177177 protected function getLength () : int
178178 {
179- return isset ($ this ->request ['length ' ])
180- ? intval ($ this ->request ['length ' ]) : 1 ;
179+ return isset ($ this ->request ['length ' ])
180+ ? intval ($ this ->request ['length ' ]) : 1 ;
181181 }
182182
183183 /**
@@ -188,8 +188,8 @@ protected function getLength() : int
188188 */
189189 protected function getDraw () : int
190190 {
191- return isset ($ this ->request ['draw ' ])
192- ? intval ($ this ->request ['draw ' ]) : 0 ;
191+ return isset ($ this ->request ['draw ' ])
192+ ? intval ($ this ->request ['draw ' ]) : 0 ;
193193 }
194194
195195 /**
@@ -307,29 +307,29 @@ protected function getSearchQuery() : string
307307 $ where = '' ;
308308 $ columns = $ this ->columns ;
309309
310- // Set where clause
310+ // Set where clause
311311 if ( $ this ->match ) {
312312 $ columns = $ this ->match ;
313313 }
314314
315- foreach ($ columns as $ key => $ column ) {
316- if ( $ column !== $ this ->key ) {
317- if ( isset ($ this ->request ['columns ' ][$ key ]) ) {
318- $ option = $ this ->request ['columns ' ][$ key ];
315+ foreach ($ columns as $ key => $ column ) {
316+ if ( $ column !== $ this ->key ) {
317+ if ( isset ($ this ->request ['columns ' ][$ key ]) ) {
318+ $ option = $ this ->request ['columns ' ][$ key ];
319319 if ( isset ($ option ['searchable ' ]) && $ option ['searchable ' ] == 'true ' ) {
320320 $ this ->search [$ column ] = $ this ->getSearchPattern ($ search );
321321 $ where .= "(` {$ column }` LIKE : {$ column }) OR " ;
322322 }
323- }
324- }
325- }
326-
327- // Format where clause
328- if ( !empty ($ where ) ) {
329- $ where = substr (trim ($ where ), 0 , -3 );
330- $ where = "WHERE {$ where }" ;
331- $ sql .= " {$ where } " ;
332- }
323+ }
324+ }
325+ }
326+
327+ // Format where clause
328+ if ( !empty ($ where ) ) {
329+ $ where = substr (trim ($ where ), 0 , -3 );
330+ $ where = "WHERE {$ where }" ;
331+ $ sql .= " {$ where } " ;
332+ }
333333 }
334334
335335 return $ sql ;
@@ -372,7 +372,7 @@ protected function getData() : array
372372 if ( $ this ->useCache ) {
373373
374374 $ cache = new Cache ();
375- $ key = $ cache ->getKey ($ this ->table , [
375+ $ key = $ cache ->getKey ($ this ->table , [
376376 'start ' => $ this ->getStart (),
377377 'length ' => $ this ->getLength (),
378378 'orderby ' => $ this ->getOrderBy (),
@@ -445,7 +445,7 @@ protected function verify(array $data)
445445 protected function hasAction () : bool
446446 {
447447 if ( isset ($ this ->request ['action ' ]) ) {
448- return ( $ this ->request ['action ' ] == 'true ' ) ;
448+ return $ this ->request ['action ' ] === 'true ' ;
449449 }
450450 return false ;
451451 }
@@ -475,7 +475,7 @@ protected function appendAction(array $data = []) : array
475475 */
476476 protected function formatData (array $ data = []) : array
477477 {
478- return $ this ->mapArray ('values ' , $ data );
478+ return $ this ->mapArray (function: 'values ' , data: $ data );
479479 }
480480
481481 /**
0 commit comments