for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sergiors\Functional;
const head = '\Sergiors\Functional\head';
/**
* @author Sérgio Rafael Siqueira <[email protected]>
*
* @param mixed $xs
* @return mixed
*/
function head($xs)
{
if ([] === $xs
|| '' === $xs
|| null === $xs
) {
return null;
}
if (is_array($xs)) {
return array_values($xs)[0];
return $xs[0];