From 9d6bdb4e77f373bc6f2a2d12b4e246bbb09e5319 Mon Sep 17 00:00:00 2001 From: Chaim Date: Sat, 1 Aug 2020 13:22:53 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ README.md | 4 ++++ src/common.php | 2 +- src/helper/Files.php | 14 ++++++++------ src/helper/Xmls.php | 8 +++++--- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 535a5f1..2eefcaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v6.0.101 / 2020-07-25 +- 优化代码 + ## v6.0.100 / 2020-07-25 - 优化淘宝客 diff --git a/README.md b/README.md index 7bcb0af..5fe5846 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,11 @@ [![Latest Unstable Version](https://poser.pugx.org/liguangchun/think-library/v/unstable)](https://packagist.org/packages/liguangchun/think-library) [![Total Downloads](https://poser.pugx.org/liguangchun/think-library/downloads)](https://packagist.org/packages/liguangchun/think-library) [![License](https://poser.pugx.org/liguangchun/think-library/license)](https://packagist.org/packages/liguangchun/think-library) +[![PHP Version](https://img.shields.io/badge/php-%3E%3D7.1-8892BF.svg)](http://www.php.net/) [![Code Health](https://hn.devcloud.huaweicloud.com/codecheck/v1/codecheck/task/codehealth.svg?taskId=1567f5ea332546c3b45f4024cf50f10b)](https://hn.devcloud.huaweicloud.com/codecheck/project/c7ff3e2d65674858bd363cb43ee6c35e/codecheck/task/1567f5ea332546c3b45f4024cf50f10b/detail) +[![Build Status](https://travis-ci.org/GC0202/ThinkLibrary.svg?branch=6.0)](https://travis-ci.org/GC0202/ThinkLibrary) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/GC0202/ThinkLibrary/badges/quality-score.png?b=6.0)](https://scrutinizer-ci.com/g/GC0202/ThinkLibrary/?branch=6.0) +[![Code Coverage](https://scrutinizer-ci.com/g/GC0202/ThinkLibrary/badges/coverage.png?b=6.0)](https://scrutinizer-ci.com/g/GC0202/ThinkLibrary/?branch=6.0) ## 依赖环境 diff --git a/src/common.php b/src/common.php index 5c8fac4..fe68d3a 100644 --- a/src/common.php +++ b/src/common.php @@ -26,7 +26,7 @@ use think\db\exception\DbException; /** * 定义当前版本 */ -const VERSION = '6.0.100'; +const VERSION = '6.0.101'; if (!function_exists('get_ip_info')) { /** diff --git a/src/helper/Files.php b/src/helper/Files.php index a77c9fe..7a07e9b 100644 --- a/src/helper/Files.php +++ b/src/helper/Files.php @@ -21,6 +21,7 @@ declare (strict_types=1); namespace DtApp\ThinkLibrary\helper; +use DtApp\ThinkLibrary\exception\DtaException; use think\Exception; use ZipArchive; @@ -35,12 +36,12 @@ class Files * 删除文件 * @param string $name 路径 * @return bool - * @throws Exception + * @throws DtaException */ public function delete(string $name): bool { if (empty($name)) { - throw new Exception('请检查需要删除文件夹的名称'); + throw new DtaException('请检查需要删除文件夹的名称'); } if (file_exists($name)) { if (unlink($name)) { @@ -54,12 +55,13 @@ class Files * 删除文件夹 * @param string $name 路径 * @return bool + * @throws DtaException * @throws Exception */ public function deletes(string $name): bool { if (empty($name)) { - throw new Exception('请检查需要删除文件夹的名称'); + throw new DtaException('请检查需要删除文件夹的名称'); } //先删除目录下的文件: $dh = opendir($name); @@ -88,12 +90,12 @@ class Files * @param string $suffix_name 需要打包的后缀名,默认.png * @param string $file_name 文件名,默认全部名 * @return bool - * @throws Exception + * @throws DtaException */ public function folderZip(string $name, string $suffix_name = '.png', string $file_name = '*'): bool { if (empty($name)) { - throw new Exception('请检查需要打包的路径名称'); + throw new DtaException('请检查需要打包的路径名称'); } try { // 获取目录下所有某个结尾的文件列表 @@ -109,7 +111,7 @@ class Files //关闭压缩包 $zip->close(); return true; - } catch (\Exception $e) { + } catch (\DtaException $e) { return false; } } diff --git a/src/helper/Xmls.php b/src/helper/Xmls.php index e097586..c1f9cab 100644 --- a/src/helper/Xmls.php +++ b/src/helper/Xmls.php @@ -21,6 +21,7 @@ declare (strict_types=1); namespace DtApp\ThinkLibrary\helper; +use DtApp\ThinkLibrary\exception\DtaException; use think\Exception; /** @@ -34,12 +35,13 @@ 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 Exception('数组数据异常!'); + throw new DtaException('数组数据异常!'); } $xml = ""; foreach ($values as $key => $val) { @@ -59,12 +61,12 @@ class Xmls * 将XML转为array * @param string $xml * @return mixed - * @throws Exception + * @throws DtaException */ public function toArray(string $xml) { if (!$xml) { - throw new Exception('xml数据异常!'); + throw new DtaException('xml数据异常!'); } libxml_disable_entity_loader(true); return json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true); -- GitLab