Factory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 32
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createRequest() 0 19 3
1
<?php
2
3
namespace Kevintweber\Gauges;
4
5
use GuzzleHttp\MessageFormatter;
6
use Psr\Log\LoggerInterface;
7
8
/**
9
 * A helper class to make creating requests easy.
10
 */
11
class Factory
12
{
13
    /**
14
     * Will return a fully built Request object.
15
     *
16
     * @param string          $token
17
     * @param array           $httpDefaults (Optional)
18
     * @param LoggerInterface $logger       (Optional)
19
     * @param string          $format       (Optional log format)
20
     *
21
     * @return Request
22
     */
23 1
    public static function createRequest(string $token,
24
                                         array $httpDefaults = array(),
25
                                         LoggerInterface $logger = null,
26
                                         string $format = null) : Request
27
    {
28 1
        $request = new Request($token, $httpDefaults);
29
30 1
        if ($logger instanceof LoggerInterface) {
31 1
            $request->setLogger($logger);
32
        }
33
34 1
        if ($format !== null) {
35 1
            $request->setMessageFormatter(
36 1
                new MessageFormatter($format)
37
            );
38
        }
39
40 1
        return $request;
41
    }
42
}
43