TProtocol   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 2
b 0
f 0
dl 0
loc 15
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A withProtocolVersion() 0 6 2
A getProtocolVersion() 0 3 1
1
<?php
2
3
namespace kalanis\RemoteRequestPsr\Traits;
4
5
6
use Psr\Http\Message\MessageInterface;
7
8
9
/**
10
 * Trait TProtocol
11
 * @package kalanis\RemoteRequestPsr\Traits
12
 * Note: Contrary the PSR requirements this class does not offer immutability
13
 * That's because you need to change request properties before you set them to RemoteRequest
14
 */
15
trait TProtocol
16
{
17
    protected string $protocol = '1.0';
18
19 1
    public function getProtocolVersion(): string
20
    {
21 1
        return $this->protocol;
22
    }
23
24 1
    public function withProtocolVersion(string $version): MessageInterface
25
    {
26 1
        if (preg_match('#(\d+)\.(\d+)#', $version)) {
27 1
            $this->protocol = $version;
28
        }
29 1
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type kalanis\RemoteRequestPsr\Traits\TProtocol which is incompatible with the type-hinted return Psr\Http\Message\MessageInterface.
Loading history...
30
    }
31
}
32