RequestFactoryMiddleware::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of Guzzle HTTP JSON-RPC
5
 *
6
 * Copyright (c) 2014 Nature Delivered Ltd. <http://graze.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @see  http://github.com/graze/guzzle-jsonrpc/blob/master/LICENSE
12
 * @link http://github.com/graze/guzzle-jsonrpc
13
 */
14
15
namespace Graze\GuzzleHttp\JsonRpc\Middleware;
16
17
use Graze\GuzzleHttp\JsonRpc\Message\MessageFactoryInterface;
18
use Psr\Http\Message\RequestInterface as HttpRequestInterface;
19
20
class RequestFactoryMiddleware extends AbstractMiddleware
21
{
22
    /**
23
     * @var MessageFactoryInterface
24
     */
25
    protected $factory;
26
27
    /**
28
     * @param MessageFactoryInterface $factory
29
     */
30 15
    public function __construct(MessageFactoryInterface $factory)
31
    {
32 15
        $this->factory = $factory;
33 15
    }
34
35
    /**
36
     * @param  HttpRequestInterface $request
37
     * @param  array                $options
38
     *
39
     * @return HttpRequestInterface
40
     */
41 1
    public function applyRequest(HttpRequestInterface $request, array $options)
42
    {
43 1
        return $this->factory->fromRequest($request);
44
    }
45
}
46