for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Nip\Collections\Traits;
trait EnumeratesValues
{
/**
* Get a value retrieving callback.
*
* @param callable|string|null $value
* @return callable
*/
protected function valueRetriever($value)
if ($this->useAsCallable($value)) {
return $value;
}
return function ($item) use ($value) {
return data_get($item, $value);
};
* Determine if the given value is callable, but not a string.
* @param mixed $value
* @return bool
protected function useAsCallable($value)
return ! is_string($value) && is_callable($value);