function first(callable $closure = null) {
        if($closure === null) {
            if(empty($this->data)) {
                return null;
            }
            
            $keys = \array_keys($this->data);
            return ($this->data[$keys[0]] ?? null);
        }
        
        foreach($this->data as $key => $val) {
            $feed = (bool) $closure($val, $key);
            if($feed) {
                return $val;
            }
        }
        
        return null;
    }
function first(callable $closure = null) {
        if($closure === null) {
            if(empty($this->data)) {
                return null;
            }
            
            $keys = \array_keys($this->data);
            return ($this->data[$keys[0]] ?? null);
        }
        
        foreach($this->data as $key => $val) {
            $feed = (bool) $closure($val, $key);
            if($feed) {
                return $val;
            }
        }
        
        return null;
    }
function first ( callable $ closure = null ) { if ( $ closure === null ) { if ( empty ( $ this -> data ) ) { return null ; } $ keys = \ array_keys ( $ this -> data ) ; return ( $ this -> data [ $ keys [ 0 ] ] ?? null ) ; } foreach ( $ this -> data as $ key => $ val ) { $ feed = ( bool ) $ closure ( $ val , $ key ) ; if ( $ feed ) { return $ val ; } } return null ; }
Returns the first element in the collection that passes a given truth test.
@param callable|null  $closure  Callback specification: `function ($value, $key): bool`
@return mixed|null
Returns the first element in the collection that passes a given truth test .