Skip to content

Commit

Permalink
fix "Undefined function camel_case()" (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
her-cat authored and Tucker-Eric committed Aug 8, 2019
1 parent 85edfce commit 61eae97
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/ModelFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,24 @@ public function getFilterMethod($key)
$methodName = str_replace('.', '', $this->drop_id ? preg_replace('/^(.*)_id$/', '$1', $key) : $key);

// Convert key to camelCase?
return $this->camel_cased_methods ? camel_case($methodName) : $methodName;
return $this->camel_cased_methods ? $this->convertToCamelCase($methodName) : $methodName;
}

/**
* Convert a string to camel case.
*
* @param $value
* @return string
*/
protected function convertToCamelCase($value)
{
if (function_exists('camel_case')) {
return camel_case($value);
}

$value = ucwords(str_replace(['-', '_'], ' ', $value));

return lcfirst(str_replace(' ', '', $value));
}

/**
Expand Down

0 comments on commit 61eae97

Please sign in to comment.