add composer metadata writer

This commit is contained in:
crazywhalecc 2023-02-28 23:00:07 +08:00 committed by Jerry
parent 470b2736b7
commit d0bbd20acc

View File

@ -16,4 +16,15 @@ class ZMUtil
{
return json_decode(file_get_contents(($path ?? SOURCE_ROOT_DIR) . '/composer.json'), true, 512, JSON_THROW_ON_ERROR);
}
/**
* 写入 composer.json
*
* @param null|string $path 路径
* @param array $content 内容数组
*/
public static function putComposerMetadata(?string $path = null, array $content = []): false|int
{
return file_put_contents(($path ?? SOURCE_ROOT_DIR) . '/composer.json', json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
}
}