1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Ivory Http Adapter package. |
5
|
|
|
* |
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Ivory\HttpAdapter; |
13
|
|
|
|
14
|
|
|
use Ivory\HttpAdapter\Message\InternalRequestInterface; |
15
|
|
|
use Symfony\Component\Stopwatch\Stopwatch; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author GeLo <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class StopwatchHttpAdapter extends PsrHttpAdapterDecorator |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var Stopwatch\Stopwatch |
24
|
|
|
*/ |
25
|
|
|
private $stopwatch; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param HttpAdapterInterface $httpAdapter |
29
|
|
|
* @param Stopwatch $stopwatch |
30
|
|
|
*/ |
31
|
45 |
|
public function __construct(HttpAdapterInterface $httpAdapter, Stopwatch $stopwatch) |
32
|
|
|
{ |
33
|
45 |
|
parent::__construct($httpAdapter); |
34
|
|
|
|
35
|
45 |
|
$this->stopwatch = $stopwatch; |
|
|
|
|
36
|
45 |
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* {@inheritdoc} |
40
|
|
|
*/ |
41
|
18 |
View Code Duplication |
protected function doSendInternalRequest(InternalRequestInterface $internalRequest) |
|
|
|
|
42
|
|
|
{ |
43
|
18 |
|
$this->stopwatch->start($name = 'ivory.http_adapter'); |
44
|
|
|
|
45
|
|
|
try { |
46
|
18 |
|
$result = parent::doSendInternalRequest($internalRequest); |
47
|
16 |
|
} catch (\Exception $e) { |
48
|
9 |
|
$this->stopwatch->stop($name); |
49
|
|
|
|
50
|
9 |
|
throw $e; |
51
|
|
|
} |
52
|
|
|
|
53
|
9 |
|
$this->stopwatch->stop($name); |
54
|
|
|
|
55
|
9 |
|
return $result; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* {@inheritdoc} |
60
|
|
|
*/ |
61
|
18 |
View Code Duplication |
protected function doSendInternalRequests(array $internalRequests) |
|
|
|
|
62
|
|
|
{ |
63
|
18 |
|
$this->stopwatch->start($name = 'ivory.http_adapter'); |
64
|
|
|
|
65
|
|
|
try { |
66
|
18 |
|
$result = parent::doSendInternalRequests($internalRequests); |
67
|
16 |
|
} catch (\Exception $e) { |
68
|
9 |
|
$this->stopwatch->stop($name); |
69
|
|
|
|
70
|
9 |
|
throw $e; |
71
|
|
|
} |
72
|
|
|
|
73
|
9 |
|
$this->stopwatch->stop($name); |
74
|
|
|
|
75
|
9 |
|
return $result; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..