Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
HttpClientContentBase | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
toHeader | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
toBody | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
createContentTypeHeader | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\Core\Http\Client; |
6 | |
7 | use PeServer\Core\Binary; |
8 | use PeServer\Core\Encoding; |
9 | use PeServer\Core\Http\HttpHeader; |
10 | use PeServer\Core\Http\ContentType; |
11 | use PeServer\Core\Text; |
12 | |
13 | abstract class HttpClientContentBase |
14 | { |
15 | #region function |
16 | |
17 | abstract public function toHeader(): HttpHeader; |
18 | |
19 | abstract public function toBody(): Binary; |
20 | |
21 | protected function createContentTypeHeader(string $mime, ?Encoding $encoding = null): HttpHeader |
22 | { |
23 | if (Text::isNullOrWhiteSpace($mime)) { |
24 | return HttpHeader::createClientRequestHeader(); |
25 | } |
26 | |
27 | $result = HttpHeader::createClientRequestHeader(); |
28 | $result->setContentType(ContentType::create($mime, $encoding)); |
29 | |
30 | return $result; |
31 | } |
32 | |
33 | #endregion |
34 | } |