Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| TimeoutException | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| getLimit | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Wikimedia\RequestTimeout; |
| 4 | |
| 5 | use Exception; |
| 6 | use Wikimedia\NormalizedException\INormalizedException; |
| 7 | use Wikimedia\NormalizedException\NormalizedExceptionTrait; |
| 8 | |
| 9 | /** |
| 10 | * The base class for timeout exceptions thrown by this library |
| 11 | */ |
| 12 | class TimeoutException extends Exception implements INormalizedException { |
| 13 | use NormalizedExceptionTrait; |
| 14 | |
| 15 | /** @var float */ |
| 16 | private $limit; |
| 17 | |
| 18 | public function __construct( $message, $limit ) { |
| 19 | $this->limit = $limit; |
| 20 | $this->normalizedMessage = $message; |
| 21 | $this->messageContext = [ 'limit' => $limit ]; |
| 22 | parent::__construct( self::getMessageFromNormalizedMessage( $message, $this->messageContext ) ); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Get the limit which was exceeded, in seconds. |
| 27 | * |
| 28 | * @return float |
| 29 | */ |
| 30 | public function getLimit() { |
| 31 | return $this->limit; |
| 32 | } |
| 33 | } |