| Total Complexity | 8 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 18 | final class History implements Journal, IteratorAggregate |
||
| 19 | { |
||
| 20 | /** @var Tuple[] */ |
||
| 21 | private $tuples = []; |
||
| 22 | |||
| 23 | /** {@inheritDoc} */ |
||
| 24 | public function addSuccess(RequestInterface $request, ResponseInterface $response) |
||
| 27 | } |
||
| 28 | |||
| 29 | /** {@inheritDoc} */ |
||
| 30 | public function addFailure(RequestInterface $request, Exception $exception) |
||
| 37 | } |
||
| 38 | |||
| 39 | public function getLastResponse(): ResponseInterface |
||
| 40 | { |
||
| 41 | if (1 > count($this->tuples)) { |
||
| 42 | throw new NoResponse; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** @var Tuple $tuple */ |
||
| 46 | $tuple = end($this->tuples); |
||
| 47 | reset($this->tuples); |
||
| 48 | |||
| 49 | $response = $tuple->getResponse(); |
||
| 50 | |||
| 51 | if (null === $response) { |
||
| 52 | throw new NoResponse; |
||
| 53 | } |
||
| 54 | |||
| 55 | return $response; |
||
| 56 | } |
||
| 57 | |||
| 58 | /** @return iterable<Tuple> */ |
||
| 59 | public function getIterator(): iterable |
||
| 64 | } |
||
| 65 | |||
| 66 | public function reset(): void |
||
| 69 | } |
||
| 70 | } |
||
| 71 |