Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
TimeoutException
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 getLimit
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Wikimedia\RequestTimeout;
4
5use Exception;
6use Wikimedia\NormalizedException\INormalizedException;
7use Wikimedia\NormalizedException\NormalizedExceptionTrait;
8
9/**
10 * The base class for timeout exceptions thrown by this library
11 */
12class 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}