Skip to content

Commit

Permalink
Merge pull request #3 from shuqingzai/analysis-0gnVd4
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
shuqingzai authored Aug 2, 2020
2 parents 686c2f8 + d9843dd commit 81a132a
Show file tree
Hide file tree
Showing 22 changed files with 688 additions and 794 deletions.
16 changes: 11 additions & 5 deletions src/Exceptions/Exception.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
<?php

declare(strict_types=1);

/*
* This file is part of the overbeck/logistics.
*
* (c) overbeck<i@overbeck.me>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Overbeck\Logistics\Exceptions;


/**
* 异常基类
* 异常基类.
*
* Class Exception
* Author ShuQingZai
* DateTime 2020/7/31 16:07
*
* @package Overbeck\Logistics\Exceptions
*/
class Exception extends \Exception
{
}
}
29 changes: 12 additions & 17 deletions src/Exceptions/GatewayAvailableException.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
<?php

declare(strict_types=1);

/*
* This file is part of the overbeck/logistics.
*
* (c) overbeck<i@overbeck.me>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Overbeck\Logistics\Exceptions;


use Overbeck\Logistics\Interfaces\GatewayAvailableInterface;
use Throwable;


/**
* 网关可用异常
* 网关可用异常.
*
* Class GatewayAvailableException
* Author ShuQingZai
* DateTime 2020/7/31 16:07
*
* @package Overbeck\Logistics\Exceptions
*/
class GatewayAvailableException extends Exception implements GatewayAvailableInterface
{
Expand All @@ -26,34 +31,25 @@ class GatewayAvailableException extends Exception implements GatewayAvailableInt

public function __construct(array $results = [], $code = 0, Throwable $previous = null)
{
$this->results = $results;
$this->results = $results;
$this->exceptions = \array_column($results, 'exception', 'gateway');

parent::__construct('The gateways have failed. You can check "\Overbeck\Logistics\Interfaces\GatewayAvailableInterface" to get the results', $code, $previous);
}


/**
* @return array
*/
public function getResults(): array
{
return $this->results;
}

/**
* @param string $gateway
*
* @return mixed|null
*/
public function getException(string $gateway)
{
return isset($this->exceptions[$gateway]) ? $this->exceptions[$gateway] : null;
}

/**
* @return array
*/
public function getExceptions(): array
{
return $this->exceptions;
Expand All @@ -66,5 +62,4 @@ public function getLastException()
{
return end($this->exceptions);
}

}
}
19 changes: 11 additions & 8 deletions src/Exceptions/GatewayErrorException.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
<?php

declare(strict_types=1);

/*
* This file is part of the overbeck/logistics.
*
* (c) overbeck<i@overbeck.me>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Overbeck\Logistics\Exceptions;


/**
* 网关发生错误异常
* 网关发生错误异常.
*
* Class GatewayErrorException
* Author ShuQingZai
* DateTime 2020/7/31 16:08
*
* @package Overbeck\Logistics\Exceptions
*/
class GatewayErrorException extends Exception
{
Expand All @@ -25,11 +31,8 @@ public function __construct(string $message, int $code = 0, array $raw = [])
parent::__construct($message, $code);
}

/**
* @return array
*/
public function getRaw(): array
{
return $this->raw;
}
}
}
17 changes: 11 additions & 6 deletions src/Exceptions/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
<?php

declare(strict_types=1);

/*
* This file is part of the overbeck/logistics.
*
* (c) overbeck<i@overbeck.me>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Overbeck\Logistics\Exceptions;


/**
* 参数异常
* 参数异常.
*
* Class InvalidArgumentException
* Author ShuQingZai
* DateTime 2020/7/31 16:08
*
* @package Overbeck\Logistics\Exceptions
*/
class InvalidArgumentException extends Exception
{

}
}
Loading

0 comments on commit 81a132a

Please sign in to comment.