Skip to content

Commit

Permalink
Merge pull request #18 from uuk020/analysis-gONVv1
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
uuk020 committed Nov 2, 2020
2 parents c5ea1dc + 7f0e5e4 commit d57707b
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 108 deletions.
11 changes: 0 additions & 11 deletions src/Channel/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ abstract class Channel
/**
* 设置请求选项.
*
* @param array $option
*
* @return \Wythe\Logistics\Channel\Channel
*/
public function setRequestOption(array $option): self
Expand All @@ -75,8 +73,6 @@ public function setRequestOption(array $option): self

/**
* 获取实例化的类名称.
*
* @return string
*/
protected function getClassName(): string
{
Expand All @@ -87,8 +83,6 @@ protected function getClassName(): string

/**
* 获取配置.
*
* @return array
*/
protected function getChannelConfig(): array
{
Expand All @@ -97,11 +91,6 @@ protected function getChannelConfig(): array

/**
* 调用查询接口.
*
* @param string $code
* @param string $company
*
* @return array
*/
abstract public function request(string $code, string $company = ''): array;

Expand Down
5 changes: 0 additions & 5 deletions src/Channel/JiSuChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public function __construct()
/**
* 请求
*
* @param string $code
* @param string $company
*
* @return array
*
* @throws \Wythe\Logistics\Exceptions\HttpException
*/
public function request(string $code, string $company = ''): array
Expand Down
10 changes: 0 additions & 10 deletions src/Channel/JuHeChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public function __construct()
/**
* 构造请求参数.
*
* @param string $code
* @param string $company
*
* @return array
*
* @throws \Wythe\Logistics\Exceptions\HttpException
*/
private function setRequestParam(string $code, string $company): array
Expand All @@ -53,11 +48,6 @@ private function setRequestParam(string $code, string $company): array
/**
* 请求
*
* @param string $code
* @param string $company
*
* @return array
*
* @throws \Exception
*/
public function request(string $code, string $company = ''): array
Expand Down
5 changes: 0 additions & 5 deletions src/Channel/KuaiDi100Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ public function __construct()
/**
* 调用快递100接口.
*
* @param string $code
* @param string $company
*
* @return array
*
* @throws \Exception
*/
public function request(string $code, string $company = ''): array
Expand Down
12 changes: 0 additions & 12 deletions src/Channel/KuaiDiBirdChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ public function __construct()
* 拼接请求URL链接.
*
* @param string $requestData 请求的数据
*
* @return array
*/
public function setRequestParam(string $requestData): array
{
Expand All @@ -70,11 +68,6 @@ public function setRequestParam(string $requestData): array

/**
* 编码
*
* @param string $data
* @param string $appKey
*
* @return string
*/
private function encrypt(string $data, string $appKey): string
{
Expand All @@ -84,11 +77,6 @@ private function encrypt(string $data, string $appKey): string
/**
* 请求
*
* @param string $code
* @param string $company
*
* @return array
*
* @throws \Exception
*/
public function request(string $code, string $company = ''): array
Expand Down
5 changes: 0 additions & 5 deletions src/Channel/ShuJuZhiHuiChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ public function __construct()
/**
* 请求
*
* @param string $code
* @param string $company
*
* @return array
*
* @throws \Wythe\Logistics\Exceptions\HttpException
*/
public function request(string $code, string $company = ''): array
Expand Down
5 changes: 0 additions & 5 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class Config
/**
* 验证规则.
*
* @param string $channel
* @throws ConfigNotFoundException
* @throws ConfigValidateException
*/
Expand All @@ -68,7 +67,6 @@ protected function validate(string $channel)
/**
* 设置配置.
*
* @param array $params
* @throws ConfigNotFoundException
* @throws ConfigValidateException
*/
Expand All @@ -82,9 +80,6 @@ public function setConfig(array $params)

/**
* 获取配置.
*
* @param string $key
* @return array
*/
public function getConfig(string $key): array
{
Expand Down
12 changes: 10 additions & 2 deletions src/Exceptions/ConfigNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@
*/
declare(strict_types=1);

namespace Wythe\Logistics\Exceptions;
/*
* This file is part of the uuk020/logistics.
*
* (c) WytheHuang<[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Wythe\Logistics\Exceptions;

class ConfigNotFoundException extends Exception
{
}
}
12 changes: 10 additions & 2 deletions src/Exceptions/ConfigValidateException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@
*/
declare(strict_types=1);

namespace Wythe\Logistics\Exceptions;
/*
* This file is part of the uuk020/logistics.
*
* (c) WytheHuang<[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Wythe\Logistics\Exceptions;

class ConfigValidateException extends Exception
{
}
}
8 changes: 0 additions & 8 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class Factory
/**
* 获取默认查询类名称.
*
* @return string
*
* @throws \Wythe\Logistics\Exceptions\Exception
*/
public function getDefault(): string
Expand All @@ -57,8 +55,6 @@ public function setDefault($name)
/**
* 数组元素存储查询对象
*
* @param string $name
*
* @return mixed
*
* @throws \Wythe\Logistics\Exceptions\InvalidArgumentException
Expand All @@ -83,10 +79,6 @@ public function createChannel(string $name = '')

/**
* 格式化类的名称.
*
* @param string $name
*
* @return string
*/
protected function formatClassName(string $name): string
{
Expand Down
18 changes: 4 additions & 14 deletions src/Logistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class Logistics

/**
* 构造函数.
*
* @param array $config
*/
public function __construct(array $config)
{
Expand All @@ -67,19 +65,16 @@ private function channelMap(string $channelName): string
'shujuzhihui' => 'shuJuZhiHui',
'jisu' => 'jiSu',
'kuaidibird' => 'kuaiDiBird',
'kuaidi100' => 'kuaiDi100'
'kuaidi100' => 'kuaiDi100',
];

return $channels[$channelName];
}

/**
* 通过接口获取物流信息.
*
* @param string $code
* @param array $channels
* @param string $company
*
* @return array
* @param array $channels
*
* @throws \Wythe\Logistics\Exceptions\InvalidArgumentException
* @throws \Wythe\Logistics\Exceptions\NoQueryAvailableException
Expand Down Expand Up @@ -129,12 +124,7 @@ public function query(string $code, $channels = ['kuaidibird'], string $company
/**
* 通过代理IP获取物流信息.
*
* @param array $proxy
* @param string $code
* @param array $channels
* @param string $company
*
* @return array
* @param array $channels
*
* @throws \Wythe\Logistics\Exceptions\InvalidArgumentException
* @throws \Wythe\Logistics\Exceptions\NoQueryAvailableException
Expand Down
6 changes: 0 additions & 6 deletions src/SupportLogistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ class SupportLogistics
/**
* 获取物流公司编码
*
* @param string $channel
* @param string $code
* @param string $companyName
*
* @return string
*
* @throws \Wythe\Logistics\Exceptions\HttpException
*/
public function getCode(string $channel, string $code, string $companyName = ''): string
Expand Down
17 changes: 0 additions & 17 deletions src/Traits/HttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ trait HttpRequest
* 设置cURL参数.
*
* @param resource $handle
* @param array $option
*/
private function setCurlCommonOption($handle, array $option = [])
{
Expand Down Expand Up @@ -69,7 +68,6 @@ private function setCurlUrlMethod($handle, $url, $params)
*
* @param string $url
* @param string|array $params
* @param array $option
*
* @return string
*
Expand All @@ -94,7 +92,6 @@ protected function get($url, $params, array $option = [])
*
* @param string $url
* @param string|array $params
* @param array $option
*
* @return bool|string
*
Expand All @@ -116,8 +113,6 @@ protected function post($url, $params, array $option = [])

/**
* 设置useragent.
*
* @return string
*/
private function setUseragent(): string
{
Expand Down Expand Up @@ -146,12 +141,6 @@ private function setUseragent(): string

/**
* GET 多线程请求
*
* @param array $urls
* @param array $params
* @param array $option
*
* @return array
*/
protected function getByQueue(array $urls = [], array $params = [], array $option = []): array
{
Expand Down Expand Up @@ -195,12 +184,6 @@ protected function getByQueue(array $urls = [], array $params = [], array $optio

/**
* POST 多线程请求
*
* @param array $urls
* @param array $params
* @param array $option
*
* @return array
*/
protected function postByQueue(array $urls = [], array $params = [], array $option = []): array
{
Expand Down
1 change: 0 additions & 1 deletion tests/CommonMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Wythe\Logistics\Tests;

use PHPUnit\Framework\TestCase;
use Wythe\Logistics\Channel\JiSuChannel;
use Wythe\Logistics\Factory;
use Wythe\Logistics\SupportLogistics;

Expand Down
9 changes: 4 additions & 5 deletions tests/LogisticsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

class LogisticsTest extends TestCase
{

public function testNotExistConfig()
{
$config = [
Expand All @@ -33,7 +32,7 @@ public function testNotExistConfig()
public function testMistakeConfig()
{
$config = [
'juhe' => ['app_key1' => 'app_key', 'vip' => false]
'juhe' => ['app_key1' => 'app_key', 'vip' => false],
];
$this->expectException(ConfigValidateException::class);
$this->expectExceptionMessage('规则验证失败');
Expand Down Expand Up @@ -175,7 +174,7 @@ public function testChannelByJuHe()
public function testChannelByShuJu()
{
$config = [
'shujuzhihui' => ['app_key' => 'app_key', 'vip' => false]
'shujuzhihui' => ['app_key' => 'app_key', 'vip' => false],
];
$response = [
'shujuzhihui' => [
Expand Down Expand Up @@ -251,7 +250,7 @@ public function testChannelByBoth()
'kuaidibird' => ['app_key' => 'app_key', 'app_secret' => 'app_secret', 'vip' => false],
'juhe' => ['app_key' => 'app_key', 'vip' => false],
'jisu' => ['app_key' => 'app_key', 'vip' => false],
'shujuzhihui' => ['app_key' => 'app_key', 'vip' => false]
'shujuzhihui' => ['app_key' => 'app_key', 'vip' => false],
];
$response = [
'kuaidi100' => [
Expand Down Expand Up @@ -347,6 +346,6 @@ public function testChannelByBoth()
];
$logistics = \Mockery::mock(Logistics::class, [$config]);
$logistics->shouldReceive('query')->andReturn($response);
$this->assertSame($response, $logistics->query('12312211', array_keys($config),'申通'));
$this->assertSame($response, $logistics->query('12312211', array_keys($config), '申通'));
}
}

0 comments on commit d57707b

Please sign in to comment.