TProtocol::withProtocolVersion()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
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