disk->exists($this->filename); } /** * Set a new array of values */ public function set(array $content): void { $this->content = $content; } /** * Return a boolean indicating if the file has changed since it was loaded */ public function isDirty(): bool { $original = collect($this->originalContent); $current = collect($this->content); return $original->diffAssoc($current)->isEmpty() && $current->diffAssoc($original)->isEmpty(); } /** * Store file on disk */ public function save(): bool { if (!$this->isDirty()) { return false; } $json = json_encode($this->content, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); $this->disk->put($this->filename, $json); $this->originalContent = $this->content; return true; } }