Completed
Push — master ( df86eb...c49bab )
by Tobias
02:44
created

SimpleGenerator::generate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Http\Client\Common\Plugin\Cache\Generator;
4
5
use Psr\Http\Message\RequestInterface;
6
7
/**
8
 * Generate a cache key from the request method, URI and body.
9
 *
10
 * @author Tobias Nyholm <[email protected]>
11
 */
12
class SimpleGenerator implements CacheKeyGenerator
13
{
14 11
    public function generate(RequestInterface $request)
15
    {
16 11
        $body = (string) $request->getBody();
17 11
        if (!empty($body)) {
18 2
            $body = ' '.$body;
19 2
        }
20
21 11
        return $request->getMethod().' '.$request->getUri().$body;
22
    }
23
}
24