Skip to content

Commit

Permalink
兼容php7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinywan committed Apr 2, 2022
1 parent 633a74a commit 54260e6
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 30 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "library",
"license": "MIT",
"require": {
"php": ">=7.4",
"php": ">=7.2",
"workerman/webman-framework": "^1.2.1"
},
"autoload": {
Expand Down
13 changes: 5 additions & 8 deletions src/Adapter/AdapterAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,27 @@ abstract class AdapterAbstract implements AdapterInterface
/**
* 被允许的文件类型列表.
*/
protected array $includes;
protected $includes;

/**
* 不被允许的文件类型列表.
*/
protected array $excludes;
protected $excludes;

/**
* 单个文件的最大字节数.
*/
protected int $singleLimit;
protected $singleLimit;

/**
* 多个文件的最大数量.
*/
protected int $totalLimit;
protected $totalLimit;

/**
* 文件上传的最大数量.
*/
protected int $nums;
protected $nums;

/**
* AdapterAbstract constructor.
Expand Down Expand Up @@ -127,8 +127,6 @@ protected function getSize(UploadFile $file): int
* @desc: 允许上传文件
*
* @author Tinywan(ShaoBo Wan)
*
* @throws UploadFileException
*/
protected function allowedFile(): bool
{
Expand Down Expand Up @@ -156,7 +154,6 @@ protected function allowedFile(): bool
*
* @author Tinywan(ShaoBo Wan)
*
* @throws UploadFileException
*/
protected function allowedFileSize()
{
Expand Down
1 change: 0 additions & 1 deletion src/Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @author Tinywan(ShaoBo Wan)
* @date 2022/3/9 10:07
*/

declare(strict_types=1);

namespace Tinywan\Storage\Adapter;
Expand Down
3 changes: 0 additions & 3 deletions src/Adapter/CosAdapter.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<?php

/**
* @desc 腾讯云对象存储适配器
* @help https://cloud.tencent.com/document/product/436
*
* @author Tinywan(ShaoBo Wan)
* @date 2022/3/13 19:54
*/

declare(strict_types=1);

namespace Tinywan\Storage\Adapter;
Expand Down
3 changes: 0 additions & 3 deletions src/Adapter/LocalAdapter.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<?php

/**
* @desc 本地适配器
*
* @author Tinywan(ShaoBo Wan)
* @date 2022/3/7 19:54
*/

declare(strict_types=1);

namespace Tinywan\Storage\Adapter;
Expand Down
13 changes: 5 additions & 8 deletions src/Adapter/OssAdapter.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<?php

/**
* @desc 阿里云OSS适配器
*
* @author Tinywan(ShaoBo Wan)
* @date 2022/3/7 19:54
*/

declare(strict_types=1);

namespace Tinywan\Storage\Adapter;
Expand All @@ -18,7 +15,7 @@

class OssAdapter extends AdapterAbstract
{
protected static ?OssClient $instance = null;
protected static $instance = null;

/**
* @desc: 阿里雲实例
Expand All @@ -41,7 +38,8 @@ public static function getInstance(): ?OssClient

/**
* @desc: 方法描述
*
* @param array $options
* @return array
* @author Tinywan(ShaoBo Wan)
*/
public function uploadFile(array $options = []): array
Expand Down Expand Up @@ -105,7 +103,6 @@ public function uploadBase64(array $options)
} catch (OssException $e) {
return $this->setError(false, $e->getMessage());
}

$imgLen = strlen($base64['1']);
$fileSize = $imgLen - ($imgLen / 8) * 2;

Expand All @@ -120,9 +117,9 @@ public function uploadBase64(array $options)

/**
* @desc: 上传服务端文件
*
* @param array $options
* @return array
* @throws OssException
*
* @author Tinywan(ShaoBo Wan)
*/
public function uploadServerFile(array $options = []): array
Expand Down
8 changes: 4 additions & 4 deletions src/Adapter/QiniuAdapter.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<?php

/**
* @desc 阿里云OSS适配器
*
* @desc 七牛云OSS适配器
* @author Tinywan(ShaoBo Wan)
* @date 2022/3/7 19:54
*/

declare(strict_types=1);

namespace Tinywan\Storage\Adapter;
Expand All @@ -32,6 +29,9 @@ public static function getInstance(): ?UploadManager
return static::$instance;
}

/**
* @return string
*/
public static function getUploadToken(): string
{
$config = config('plugin.tinywan.storage.app.storage.qiniu');
Expand Down
3 changes: 1 addition & 2 deletions src/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @author Tinywan(ShaoBo Wan)
* @date 2022/3/7 20:03
*/

declare(strict_types=1);

namespace Tinywan\Storage;
Expand All @@ -15,9 +14,9 @@
/**
* @see Storage
* @mixin Storage
*
* @method static uploadFile(array $config = []) 上传文件
* @method static uploadBase64(array $config = []) 上传Base64文件
* @method static uploadServerFile(array $config = []) 上传服务端文件
*/
class Storage
{
Expand Down

0 comments on commit 54260e6

Please sign in to comment.