public static function setContent(string $path, $data, bool $createIfDoesntExist = false)
    {
        if ($createIfDoesntExist && !is_dir(dirname($path))) {
            mkdir(dirname($path), 0777, true);
        }
        
        if (empty($data)) {
            // ignore the result because empty string returns faulty when calling file_put_contents
            file_put_contents($path, $data);
            return;
        }
        
        if (!file_put_contents($path, $data)) {
            FileException::throw($path, "Unable to write file!");
        }
    }