<?php

namespace MenulisAi\Pdfgen\Document;

use Exception;

class Document
{
    protected $object;

    protected function openFile(string $path)
    {
        $file = file_get_contents($path);
        if ($file === false) {
            throw new Exception("Unable to read or open the file", 1);
        }

        $data = json_decode($file);
        if (json_last_error() !== JSON_ERROR_NONE) {
            // Handle error if the JSON could not be parsed
            throw new Exception("Error read the json file: " . json_last_error_msg(), 1);
        }

        $this->object = $data;
    }
}
