<?php

namespace OSM;

use OSM\Element\Element;

class OSM
{
    public array $elements = [];

    public static function createFromJson($json)
    {
        $array = json_decode($json, true);

        $instance = new self();

        $items = $array['elements'];
        foreach ($items as $item) {
            $element = Element::createFromArray($item);
            $instance->elements[] = $element;
        }

        return $instance;
    }
}
