Conditions | 4 |
Paths | 2 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
13 | public function setBody(string $body) |
||
14 | { |
||
15 | $find = null; |
||
16 | preg_match_all('/^([A-Z].*?): (.*)$/m', $body, $find); |
||
17 | if ($find[0]) { |
||
18 | foreach ($find[1] as $k => $header) { |
||
19 | $method = 'add' . ucfirst($header); |
||
20 | if (method_exists($this, $method)) { |
||
21 | $this->{$method}($find[2][$k]); |
||
22 | } else { |
||
23 | $this->setHeader($header, $find[2][$k]); |
||
24 | } |
||
25 | } |
||
26 | |||
27 | preg_match("/\n{2,}(.*)$/s", $body, $find); |
||
28 | |||
29 | $body = $find[1]; |
||
30 | } |
||
31 | return parent::setBody($body); |
||
32 | } |
||
35 |