rector/src/FileSystem/JsonFileSystem.php
Tomas Votruba 695c190be3 Updated Rector to commit 94b5561ca87ee6825a098c7c506b774582bf3354
94b5561ca8 chore: bump min version of github actions (fix deprecations) (#5675)
2024-03-01 20:02:28 +00:00

27 lines
674 B
PHP

<?php
declare (strict_types=1);
namespace Rector\FileSystem;
use RectorPrefix202403\Nette\Utils\FileSystem;
use RectorPrefix202403\Nette\Utils\Json;
final class JsonFileSystem
{
/**
* @return array<string, mixed>
*/
public static function readFilePath(string $filePath) : array
{
$fileContents = FileSystem::read($filePath);
return Json::decode($fileContents, Json::FORCE_ARRAY);
}
/**
* @param array<string, mixed> $data
*/
public static function writeFile(string $filePath, array $data) : void
{
$json = Json::encode($data, Json::PRETTY);
FileSystem::write($filePath, $json, null);
}
}