public static function fromJson($json)
    {
        if (!is_object($json)) {
            $json = json_decode($json);
        }
        $collection = new static();

        foreach ($json->patches as $package => $patches) {
            foreach ($patches as $patch_json) {
                $patch = Patch::fromJson($patch_json);
                $collection->addPatch($patch);
            }
        }

        return $collection;
    }