Skip to content

Commit

Permalink
Merge pull request #22 from Hi-Folks/feat/docblock-savetojson
Browse files Browse the repository at this point in the history
Update ExportableBlock.php
  • Loading branch information
roberto-butti authored Oct 7, 2024
2 parents c094a0e + f5ee88a commit 8b1bf1f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Traits/ExportableBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,18 @@ public function toYaml(): string

/**
* Saves the JSON String to a file
* @param string $filename
* @param bool $overwrite
* @return bool
* @param string $filename file name for example "./file.json"
* @param bool $overwrite if the file already exists you can force overwriting
* @return bool true if the file is saved, if already exists and you don't want to
* force overwiting the file it returns false
*/
public function saveToJson(string $filename, bool $overwrite = false): bool
{
if (file_exists($filename) && !$overwrite) {
return false;
}

$result = file_put_contents($filename, $this->toJson());
file_put_contents($filename, $this->toJson());
return true;
}
}

0 comments on commit 8b1bf1f

Please sign in to comment.