src/Incoming/Structure/RecursiveInputStructureFactory.php
protected static function buildFromTraversable(Traversable $data): Structure
    {
        $is_map = false;

        // Traverse through the data, but only check the first item's key
        foreach ($data as $key => &$val) {
            $is_map = $is_map || !is_int($key);

            $val = self::attemptBuildTraversableLike($val);
        }

        if ($is_map) {
            return Map::fromTraversable($data);
        }

        return FixedList::fromTraversable($data);
    }
protected static function buildFromTraversable(Traversable $data): Structure
    {
        $is_map = false;

        // Traverse through the data, but only check the first item's key
        foreach ($data as $key => &$val) {
            $is_map = $is_map || !is_int($key);

            $val = self::attemptBuildTraversableLike($val);
        }

        if ($is_map) {
            return Map::fromTraversable($data);
        }

        return FixedList::fromTraversable($data);
    }
protected static function buildFromTraversable ( Traversable $ data ) : Structure { $ is_map = false ; // Traverse through the data, but only check the first item's key foreach ( $ data as $ key => & $ val ) { $ is_map = $ is_map || ! is_int ( $ key ) ; $ val = self :: attemptBuildTraversableLike ( $ val ) ; } if ( $ is_map ) { return Map :: fromTraversable ( $ data ) ; } return FixedList :: fromTraversable ( $ data ) ; }
Build a structure from data in a Traversable instance.

@param Traversable $data The input data.
@return Structure The built structure.
Build a structure from data in a Traversable instance .