1 | <?php declare(strict_types=1); |
||
18 | class Oauth1Middleware implements MiddlewareInterface |
||
19 | { |
||
20 | use PostTrait; |
||
21 | use ErrorTrait; |
||
22 | |||
23 | /** |
||
24 | * @var LoopInterface |
||
25 | */ |
||
26 | private $loop; |
||
27 | |||
28 | /** |
||
29 | * @param LoopInterface $loop |
||
30 | */ |
||
31 | 10 | public function __construct(LoopInterface $loop) |
|
32 | { |
||
33 | 10 | $this->loop = $loop; |
|
34 | 10 | } |
|
35 | |||
36 | /** |
||
37 | * @param RequestInterface $request |
||
38 | * @param array $options |
||
39 | * @return CancellablePromiseInterface |
||
40 | */ |
||
41 | 10 | public function pre( |
|
42 | RequestInterface $request, |
||
43 | string $transactionId, |
||
44 | array $options = [] |
||
45 | ): CancellablePromiseInterface { |
||
46 | 10 | if (!$this->validateOptions($options)) { |
|
47 | 9 | return resolve($request); |
|
48 | } |
||
49 | |||
50 | 1 | return futurePromise($this->loop, [$request, $options])->then(function ($args) { |
|
51 | 1 | return resolve($this->signRequest(...$args)); |
|
|
|||
52 | 1 | }); |
|
53 | } |
||
54 | |||
55 | 10 | private function validateOptions(array $options): bool |
|
78 | |||
79 | 1 | private function signRequest(RequestInterface $request, array $options): RequestInterface |
|
80 | { |
||
89 | } |
||
90 |
This check looks for function calls that miss required arguments.