| Total Complexity | 8 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | final class ArrayOffsetHttpFields implements HttpFieldsInterface |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | private $offset; |
||
| 22 | |||
| 23 | |||
| 24 | /** |
||
| 25 | * ArrayOffsetHttpFields constructor. |
||
| 26 | * |
||
| 27 | * @param string $offset The field name |
||
| 28 | */ |
||
| 29 | 315 | public function __construct(string $offset) |
|
| 32 | 315 | } |
|
| 33 | |||
| 34 | /** |
||
| 35 | * {@inheritdoc} |
||
| 36 | */ |
||
| 37 | 114 | public function extract($httpFields) |
|
| 38 | { |
||
| 39 | 114 | if (!is_array($httpFields) || !isset($httpFields[$this->offset])) { |
|
| 40 | 29 | return null; |
|
| 41 | } |
||
| 42 | |||
| 43 | 90 | return $httpFields[$this->offset]; |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * {@inheritdoc} |
||
| 48 | */ |
||
| 49 | 11 | public function contains($httpFields): bool |
|
| 50 | { |
||
| 51 | 11 | return isset($httpFields[$this->offset]); |
|
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * {@inheritdoc} |
||
| 56 | */ |
||
| 57 | 7 | public function format($value) |
|
| 58 | { |
||
| 59 | 7 | return [$this->offset => $value]; |
|
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * {@inheritdoc} |
||
| 64 | */ |
||
| 65 | 52 | public function get(?HttpFieldPath $path = null): HttpFieldPath |
|
| 68 | } |
||
| 69 | } |
||
| 70 |