- 优化错误

v6
Chaim 4 years ago
parent 48e73532a2
commit d80da81679

@ -17,7 +17,7 @@ declare (strict_types=1);
namespace DtApp\ThinkLibrary\helper;
use DtApp\ThinkLibrary\exception\DtaException;
use think\Exception;
use ZipArchive;
/**
@ -32,11 +32,11 @@ class Files
* 删除文件
* @param string $name 路径
* @return bool
* @throws DtaException
* @throws Exception
*/
public function delete(string $name): bool
{
if (empty($name)) throw new DtaException('请检查需要删除文件夹的名称');
if (empty($name)) throw new Exception('请检查需要删除文件夹的名称');
if (file_exists($name)) if (unlink($name)) return true;
return false;
}
@ -45,11 +45,11 @@ class Files
* 删除文件夹
* @param string $name 路径
* @return bool
* @throws DtaException
* @throws Exception
*/
public function deletes(string $name): bool
{
if (empty($name)) throw new DtaException('请检查需要删除文件夹的名称');
if (empty($name)) throw new Exception('请检查需要删除文件夹的名称');
//先删除目录下的文件:
$dh = opendir($name);
while ($file = readdir($dh)) {
@ -71,11 +71,11 @@ class Files
* @param string $suffix_name 需要打包的后缀名,默认.png
* @param string $file_name 文件名,默认全部名
* @return bool
* @throws DtaException
* @throws Exception
*/
public function folderZip(string $name, string $suffix_name = '.png', string $file_name = '*'): bool
{
if (empty($name)) throw new DtaException('请检查需要打包的路径名称');
if (empty($name)) throw new Exception('请检查需要打包的路径名称');
try {
// 获取目录下所有某个结尾的文件列表
$list = glob($name . "{$file_name}.{$suffix_name}");

@ -16,7 +16,7 @@
namespace DtApp\ThinkLibrary\helper;
use DtApp\ThinkLibrary\exception\DtaException;
use think\Exception;
/**
* XML管理类
@ -30,11 +30,11 @@ class Xmls
* 数组转换为xml
* @param array $values 数组
* @return string
* @throws DtaException
* @throws Exception
*/
public function toXml(array $values)
{
if (!is_array($values) || count($values) <= 0) throw new DtaException('数组数据异常!');
if (!is_array($values) || count($values) <= 0) throw new Exception('数组数据异常!');
$xml = "<xml>";
foreach ($values as $key => $val) {
if (is_array($val)) {
@ -53,11 +53,11 @@ class Xmls
* 将XML转为array
* @param string $xml
* @return mixed
* @throws DtaException
* @throws Exception
*/
public function toArray(string $xml)
{
if (!$xml) throw new DtaException('xml数据异常');
if (!$xml) throw new Exception('xml数据异常');
libxml_disable_entity_loader(true);
return json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
}

Loading…
Cancel
Save