public static function first(array $data, ?string $key = null)
    {
        if (count($data) === 0) {
            return null;
        }
        reset($data);
        $element = current($data);
        if ($key !== null && is_array($element) && isset($element[$key])) {
            return $element[$key];
        }
        return $element;
    }
public static function first(array $data, ?string $key = null)
    {
        if (count($data) === 0) {
            return null;
        }
        reset($data);
        $element = current($data);
        if ($key !== null && is_array($element) && isset($element[$key])) {
            return $element[$key];
        }
        return $element;
    }
public static function first ( array $ data , ? string $ key = null ) { if ( count ( $ data ) === 0 ) { return null ; } reset ( $ data ) ; $ element = current ( $ data ) ; if ( $ key !== null && is_array ( $ element ) && isset ( $ element [ $ key ] ) ) { return $ element [ $ key ] ; } return $ element ; }
Get first element of array.

@param mixed[] $data
@param string $key Get key from element if array. Default null.
@return mixed
Get first element of array .