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

SimpleGenerator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 0 9 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