RequestSignerPlugin   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 3
c 1
b 0
f 1
dl 0
loc 11
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A handleRequest() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace IonBazan\AliyunSigner\HttPlug;
6
7
use Http\Client\Common\Plugin;
8
use Http\Promise\Promise;
9
use IonBazan\AliyunSigner\RequestSigner;
10
use Psr\Http\Message\RequestInterface;
11
12
class RequestSignerPlugin implements Plugin
13
{
14
    public function __construct(protected readonly RequestSigner $requestSigner)
15
    {
16
    }
17
18
    public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
19
    {
20
        $request = $this->requestSigner->signRequest($request);
21
22
        return $next($request);
23
    }
24
}
25