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