diff --git a/CHANGELOG.md b/CHANGELOG.md index 535a5f159b964413f82c18b7637e7af819649318..2eefcafe19748a6c30f3814c5f1ede032e52bdab 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 7bcb0af8b7953d7f5315126ee678215a6a11e676..5fe584695070350418f4878e007c75107ea5668f 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 5c8fac44aeaf9dcdeccfa6ec2f35a91267f0490f..fe68d3af573043e55dc951f1aaa668d32f9daf69 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 a77c9fe5c740e3fa5ae813af7b255d6f6adbc04c..7a07e9b196b7db10f28de4f7bd8ad88b330bac2b 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 e0975869ab529a4c4ebc9fd3ee39e428dd534371..c1f9cabc4022b318eee9ff13ef7408372db5f3a5 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);