• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lmc-eu / matej-client-php / 7529439147

15 Jan 2024 01:18PM UTC coverage: 100.0%. Remained the same
7529439147

Pull #145

github

web-flow
Bump actions/checkout from 3 to 4

Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #145: Bump actions/checkout from 3 to 4

712 of 712 relevant lines covered (100.0%)

35.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/Http/Plugin/ExceptionPlugin.php
1
<?php declare(strict_types=1);
2

3
namespace Lmc\Matej\Http\Plugin;
4

5
use Fig\Http\Message\StatusCodeInterface;
6
use Http\Client\Common\Plugin;
7
use Http\Promise\Promise;
8
use Lmc\Matej\Exception\AuthorizationException;
9
use Lmc\Matej\Exception\RequestException;
10
use Psr\Http\Message\RequestInterface;
11
use Psr\Http\Message\ResponseInterface;
12

13
/**
14
 * @internal
15
 */
16
final class ExceptionPlugin implements Plugin
17
{
18
    public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
19
    {
20
        /** @var Promise $promise */
21
        $promise = $next($request);
49✔
22

23
        return $promise->then(function (ResponseInterface $response) use ($request) {
49✔
24
            return $this->transformResponseToException($request, $response);
49✔
25
        });
49✔
26
    }
27

28
    private function transformResponseToException(
29
        RequestInterface $request,
30
        ResponseInterface $response
31
    ): ResponseInterface {
32
        $responseCode = $response->getStatusCode();
49✔
33

34
        if ($responseCode === StatusCodeInterface::STATUS_UNAUTHORIZED) {
49✔
35
            throw AuthorizationException::fromRequestAndResponse($request, $response);
7✔
36
        }
37

38
        if ($responseCode >= 400 && $responseCode < 600) {
42✔
39
            // TODO: use more specific exceptions
40
            throw new RequestException($response->getReasonPhrase(), $request, $response);
28✔
41
        }
42

43
        return $response;
14✔
44
    }
45
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc