for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Terranet\Administrator\Field\Traits;
use Illuminate\Database\Eloquent\Model;
use Terranet\Presentable\PresentableInterface;
trait HasValuePresenter
{
/**
* Check if a model has field's presenter.
*
* @param Model $model
* @param string $field
* @return null|callable
*/
public function hasPresenter(Model $model, string $field): ?callable
return $model instanceof PresentableInterface
&& method_exists($model->present(), $method = $this->presenterMethod($field))
? [$model->present(), $method]
: null;
}
* @param callable $presenter
* @return mixed
public function callPresenter(callable $presenter)
return call_user_func_array($presenter, [$this->value()]);
value()
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
return call_user_func_array($presenter, [$this->/** @scrutinizer ignore-call */ value()]);
* @param string $fieldName
* @return string
public function presenterMethod(string $fieldName): string
return 'admin'.title_case(camel_case($fieldName));