Skip to content

Commit

Permalink
code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jupitern committed Jun 19, 2019
1 parent 29547d6 commit 7d58739
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Examples/test1.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
->attr('td', 'data-text', 'bla bla bla')
->css('th', 'color', 'green')
->css('td', 'width', '50%')
->css('td', 'background-color', '#ccc', true)
->css('td', 'background-color', '#ccc')
->add()
->column()
->title('Age')
Expand Down
2 changes: 1 addition & 1 deletion src/Examples/test2.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
->filter($filterData)
->css('td', 'color', 'green')
->css('td', 'width', '50%')
->css('td', 'background-color', '#ccc', true)
->css('td', 'background-color', '#ccc')
->add()
->column()
->title('Age')
Expand Down
4 changes: 2 additions & 2 deletions src/Table/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function instance()
*/
public function setData($data)
{
$this->data = $this->isJson($data) ? json_decode($data) : $data;
$this->data = self::isJson($data) ? json_decode($data) : $data;

return $this;
}
Expand Down Expand Up @@ -170,7 +170,7 @@ public function render($returnOutput = false)
}


private function isJson($string)
public static function isJson($string)
{
if (!is_string($string)) return false;
json_decode($string);
Expand Down
17 changes: 1 addition & 16 deletions src/Table/TableColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function css($elem, $attr, $value)
*/
public function filter($data = null)
{
$this->filterData = $this->isJson($data) ? json_decode($data) : $data;
$this->filterData = Table::isJson($data) ? json_decode($data) : $data;
$this->filter = true;
$this->tableInstance->hasFilters = true;

Expand Down Expand Up @@ -193,21 +193,6 @@ public function renderBody( &$row )
}


/**
* Check if string if json
*
* @param $string
* @return bool
*/
private function isJson($string)
{
if (!is_string($string)) return false;
json_decode($string);

return (json_last_error() == JSON_ERROR_NONE);
}


/**
* @param string $str
* @return mixed
Expand Down

0 comments on commit 7d58739

Please sign in to comment.