Completed
Push — master ( 96ecdf...475a08 )
by Andreas
02:03
created

AbstractClient   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 66.67%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
authenticate() 0 1 ?
A sendRequest() 0 13 2
A discoverClient() 0 7 1
1
<?php
2
3
namespace Larium\Pay\Client;
4
5
use Larium\Http\Client;
6
use Psr\Http\Message\RequestInterface;
7
8
abstract class AbstractClient
9
{
10
    abstract protected function authenticate(RequestInterface $request);
11
12 1
    protected function sendRequest(RequestInterface $request)
13
    {
14 1
        $request = $this->authenticate($request);
15
16 1
        $response = $this->discoverClient()->sendRequest($request);
17
18 1
        if ($request->getBody()->isSeekable()) {
19 1
            $request->getBody()->rewind();
20 1
        }
21 1
        $this->rawRequest = $request->getBody()->__toString();
0 ignored issues
show
Bug introduced by
The property rawRequest does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
22
23 1
        return $response;
24
    }
25
26
    protected function discoverClient()
27
    {
28
        $client = new Client();
29
        $client->setOptions($this->options);
0 ignored issues
show
Bug introduced by
The property options does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
30
31
        return $client;
32
    }
33
}
34