Skip to content

Commit

Permalink
isCallable function added to filter random strings acting like callables
Browse files Browse the repository at this point in the history
  • Loading branch information
jupitern committed Nov 23, 2019
1 parent 7d58739 commit 47cb7d2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Table/TableColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function renderHeader()
return "";
}

if (empty($this->title) && !is_callable($this->value)) {
if (empty($this->title) && !$this->isCallable($this->value)) {
if ($this->tableInstance->titlesMode == 'underscore') $this->title = $this->underscoreToTitle($this->value);
elseif ($this->tableInstance->titlesMode == 'camelcase') $this->title = $this->camelToTitle($this->value);
}
Expand Down Expand Up @@ -178,7 +178,7 @@ public function renderBody( &$row )
$css = $this->css['td']->render('{prop}:{val}; ');

$val = "";
if (is_callable($this->value)) {
if ($this->isCallable($this->value)) {
$val = $this->value;
$val = $val($row);
}
Expand Down Expand Up @@ -216,6 +216,15 @@ private function underscoreToTitle($str)

return $str;
}




/**
* @param string $var
* @return boolean
*/
private function isCallable($var)
{
return (!is_string($var) && is_callable($var)) || (is_object($var) && $var instanceof \Closure);
}

}

0 comments on commit 47cb7d2

Please sign in to comment.