Skip to content

Commit 7d58739

Browse files
committed
code improvements
1 parent 29547d6 commit 7d58739

File tree

4 files changed

+5
-20
lines changed

4 files changed

+5
-20
lines changed

src/Examples/test1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
->attr('td', 'data-text', 'bla bla bla')
2929
->css('th', 'color', 'green')
3030
->css('td', 'width', '50%')
31-
->css('td', 'background-color', '#ccc', true)
31+
->css('td', 'background-color', '#ccc')
3232
->add()
3333
->column()
3434
->title('Age')

src/Examples/test2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
->filter($filterData)
2626
->css('td', 'color', 'green')
2727
->css('td', 'width', '50%')
28-
->css('td', 'background-color', '#ccc', true)
28+
->css('td', 'background-color', '#ccc')
2929
->add()
3030
->column()
3131
->title('Age')

src/Table/Table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function instance()
4040
*/
4141
public function setData($data)
4242
{
43-
$this->data = $this->isJson($data) ? json_decode($data) : $data;
43+
$this->data = self::isJson($data) ? json_decode($data) : $data;
4444

4545
return $this;
4646
}
@@ -170,7 +170,7 @@ public function render($returnOutput = false)
170170
}
171171

172172

173-
private function isJson($string)
173+
public static function isJson($string)
174174
{
175175
if (!is_string($string)) return false;
176176
json_decode($string);

src/Table/TableColumn.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function css($elem, $attr, $value)
9797
*/
9898
public function filter($data = null)
9999
{
100-
$this->filterData = $this->isJson($data) ? json_decode($data) : $data;
100+
$this->filterData = Table::isJson($data) ? json_decode($data) : $data;
101101
$this->filter = true;
102102
$this->tableInstance->hasFilters = true;
103103

@@ -193,21 +193,6 @@ public function renderBody( &$row )
193193
}
194194

195195

196-
/**
197-
* Check if string if json
198-
*
199-
* @param $string
200-
* @return bool
201-
*/
202-
private function isJson($string)
203-
{
204-
if (!is_string($string)) return false;
205-
json_decode($string);
206-
207-
return (json_last_error() == JSON_ERROR_NONE);
208-
}
209-
210-
211196
/**
212197
* @param string $str
213198
* @return mixed

0 commit comments

Comments
 (0)