优化代码 && 完善 phpdoc

This commit is contained in:
yansongda 2018-09-02 16:30:41 +08:00
parent 5a2cfaef76
commit 8b8adc179d
13 changed files with 52 additions and 56 deletions

View File

@ -4,4 +4,26 @@ namespace Yansongda\Pay\Exceptions;
class Exception extends \Exception
{
/**
* Raw error info.
*
* @var array
*/
public $raw;
/**
* Bootstrap.
*
* @author yansongda <me@yansonga.cn>
*
* @param string $message
* @param array|string $raw
* @param int|string $code
*/
public function __construct($message, $raw = [], $code = 9999)
{
$this->raw = is_array($raw) ? $raw : [$raw];
parent::__construct($message, intval($code));
}
}

View File

@ -4,13 +4,6 @@ namespace Yansongda\Pay\Exceptions;
class GatewayException extends Exception
{
/**
* Raw error info.
*
* @var array|string
*/
public $raw;
/**
* Bootstrap.
*
@ -20,10 +13,8 @@ class GatewayException extends Exception
* @param array|string $raw
* @param int|string $code
*/
public function __construct($message, $raw = '', $code = 4)
public function __construct($message, $raw = [], $code = 4)
{
parent::__construct($message, intval($code));
$this->raw = $raw;
parent::__construct($message, $raw, $code);
}
}

View File

@ -4,13 +4,6 @@ namespace Yansongda\Pay\Exceptions;
class InvalidArgumentException extends Exception
{
/**
* Raw error info.
*
* @var array|string
*/
public $raw;
/**
* Bootstrap.
*
@ -20,10 +13,8 @@ class InvalidArgumentException extends Exception
* @param array|string $raw
* @param int|string $code
*/
public function __construct($message, $raw = '', $code = 3)
public function __construct($message, $raw = [], $code = 3)
{
parent::__construct($message, intval($code));
$this->raw = $raw;
parent::__construct($message, $raw, $code);
}
}

View File

@ -4,13 +4,6 @@ namespace Yansongda\Pay\Exceptions;
class InvalidConfigException extends Exception
{
/**
* Raw error info.
*
* @var array|string
*/
public $raw;
/**
* Bootstrap.
*
@ -20,10 +13,8 @@ class InvalidConfigException extends Exception
* @param array|string $raw
* @param int|string $code
*/
public function __construct($message, $raw = '', $code = 2)
public function __construct($message, $raw = [], $code = 2)
{
parent::__construct($message, intval($code));
$this->raw = $raw;
parent::__construct($message, $raw, $code);
}
}

View File

@ -4,13 +4,6 @@ namespace Yansongda\Pay\Exceptions;
class InvalidGatewayException extends Exception
{
/**
* Raw error info.
*
* @var array|string
*/
public $raw;
/**
* Bootstrap.
*
@ -20,10 +13,8 @@ class InvalidGatewayException extends Exception
* @param array|string $raw
* @param int|string $code
*/
public function __construct($message, $raw = '', $code = 1)
public function __construct($message, $raw = [], $code = 1)
{
parent::__construct($message, intval($code));
$this->raw = $raw;
parent::__construct($message, $raw, $code);
}
}

View File

@ -4,13 +4,6 @@ namespace Yansongda\Pay\Exceptions;
class InvalidSignException extends Exception
{
/**
* Raw error info.
*
* @var array|string
*/
public $raw;
/**
* Bootstrap.
*
@ -20,10 +13,8 @@ class InvalidSignException extends Exception
* @param array|string $raw
* @param int|string $code
*/
public function __construct($message, $raw = '', $code = 5)
public function __construct($message, $raw = [], $code = 5)
{
parent::__construct($message, intval($code));
$this->raw = $raw;
parent::__construct($message, $raw, $code);
}
}

View File

@ -130,7 +130,7 @@ class Support
}
/**
* Verfiy sign.
* Verify sign.
*
* @author yansongda <me@yansonga.cn>
*

View File

@ -182,6 +182,7 @@ class Wechat implements GatewayApplicationInterface
*
* @throws GatewayException
* @throws InvalidSignException
* @throws \Yansongda\Pay\Exceptions\InvalidArgumentException
*
* @return Collection
*/
@ -207,6 +208,7 @@ class Wechat implements GatewayApplicationInterface
*
* @throws GatewayException
* @throws InvalidSignException
* @throws \Yansongda\Pay\Exceptions\InvalidArgumentException
*
* @return Collection
*/
@ -249,6 +251,7 @@ class Wechat implements GatewayApplicationInterface
*
* @throws GatewayException
* @throws InvalidSignException
* @throws \Yansongda\Pay\Exceptions\InvalidArgumentException
*
* @return Collection
*/

View File

@ -15,7 +15,9 @@ class MiniappGateway extends MpGateway
* @param string $endpoint
* @param array $payload
*
* @throws \Yansongda\Pay\Exceptions\GatewayException
* @throws \Yansongda\Pay\Exceptions\InvalidArgumentException
* @throws \Yansongda\Pay\Exceptions\InvalidSignException
*
* @return Collection
*/

View File

@ -16,7 +16,9 @@ class MpGateway extends Gateway
* @param string $endpoint
* @param array $payload
*
* @throws \Yansongda\Pay\Exceptions\GatewayException
* @throws \Yansongda\Pay\Exceptions\InvalidArgumentException
* @throws \Yansongda\Pay\Exceptions\InvalidSignException
*
* @return Collection
*/

View File

@ -14,6 +14,10 @@ class PosGateway extends Gateway
* @param string $endpoint
* @param array $payload
*
* @throws \Yansongda\Pay\Exceptions\GatewayException
* @throws \Yansongda\Pay\Exceptions\InvalidArgumentException
* @throws \Yansongda\Pay\Exceptions\InvalidSignException
*
* @return Collection
*/
public function pay($endpoint, array $payload): Collection

View File

@ -15,6 +15,10 @@ class ScanGateway extends Gateway
* @param string $endpoint
* @param array $payload
*
* @throws \Yansongda\Pay\Exceptions\GatewayException
* @throws \Yansongda\Pay\Exceptions\InvalidArgumentException
* @throws \Yansongda\Pay\Exceptions\InvalidSignException
*
* @return Collection
*/
public function pay($endpoint, array $payload): Collection

View File

@ -15,6 +15,10 @@ class WapGateway extends Gateway
* @param string $endpoint
* @param array $payload
*
* @throws \Yansongda\Pay\Exceptions\GatewayException
* @throws \Yansongda\Pay\Exceptions\InvalidArgumentException
* @throws \Yansongda\Pay\Exceptions\InvalidSignException
*
* @return Response
*/
public function pay($endpoint, array $payload): Response