for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Koch\Casters\Behavior;
use Illuminate\Database\Eloquent\Model;
trait BuildsCastQueries
{
/**
* Builds up the cast query.
*
* @param string $old
* @param string $query
* @param \Illuminate\Database\Eloquent\Model $model
* @param array &$transformed
* @return array
*/
protected function parse($old, $query, Model $model, &$transformed)
$key = $old;
$value = $model->$old;
foreach (explode('|', $query) as $command) {
list($function, $args) = explode(':', $command);
$args = array_merge([&$key, &$value, $model], explode(',', $args));
call_user_func_array([$this, $function], $args);
}
return $transformed[$key] = $value;
* Adjusts the name of given field.
* @param string &$key
* @param string &$value
* @param string $newName
* @return void
protected function name(&$key, &$value, Model $model, $newName)
$value
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$model
$key = $newName;
* Adjusts the data type of given field.
* @param string $type
protected function type(&$key, &$value, Model $model, $type)
$key
settype($value, $type);
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.