1 | <?php |
||
19 | trait HeaderFactoryTrait |
||
20 | { |
||
21 | /** |
||
22 | * Factory create header from string. |
||
23 | * |
||
24 | * @param string $headerLine |
||
25 | * |
||
26 | * @return $this |
||
27 | */ |
||
28 | public static function fromString($headerLine) |
||
29 | { |
||
30 | if (null === $headerName = static::getHeaderName()) { |
||
31 | GenericHeader::assertEmptyHeaderFieldName($headerName); |
||
32 | } |
||
33 | |||
34 | list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($headerLine); |
||
35 | |||
36 | return static::create($fieldName, $fieldValue); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Factory create header. |
||
41 | * |
||
42 | * @param string $fieldName |
||
43 | * @param string $fieldValue |
||
44 | * |
||
45 | * @return $this |
||
46 | */ |
||
47 | public static function create($fieldName, $fieldValue) |
||
53 | |||
54 | /** |
||
55 | * Header name accessor. |
||
56 | * |
||
57 | * @return string|null |
||
58 | */ |
||
59 | protected static function getHeaderName() |
||
73 | } |
||
74 |