alex-kalanis /
remote-request-psr
| 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
Loading history...
|
|||
| 30 | } |
||
| 31 | } |
||
| 32 |