| Total Complexity | 4 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | abstract class Parameter |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var string Name. |
||
| 18 | */ |
||
| 19 | protected $name; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var string Value. |
||
| 23 | */ |
||
| 24 | protected $value; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Construct parameter from string. |
||
| 28 | * |
||
| 29 | * @param string $parameter Parameter string. |
||
| 30 | * @return self Parameter generated based on the string. |
||
| 31 | */ |
||
| 32 | 2 | public static function fromString(string $parameter): self |
|
| 33 | { |
||
| 34 | 2 | $regEx = '{^' . Rfc6266::DISPOSITION_PARM_EXTENDED . '$}'; |
|
| 35 | 2 | if (preg_match($regEx, $parameter) === 1) { |
|
| 36 | 1 | return ExtendedParameter::fromString($parameter); |
|
| 37 | } |
||
| 38 | |||
| 39 | 1 | return RegularParameter::fromString($parameter); |
|
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @return string String representation of the parameter. |
||
| 44 | */ |
||
| 45 | abstract public function __toString(): string; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @return string Name. |
||
| 49 | */ |
||
| 50 | 2 | public function getName(): string |
|
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @param string $name Name. |
||
| 57 | */ |
||
| 58 | abstract public function setName(string $name): void; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return string Value. |
||
| 62 | */ |
||
| 63 | 2 | public function getValue(): string |
|
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @param string $value Value. |
||
| 70 | */ |
||
| 71 | abstract public function setValue(string $value): void; |
||
| 72 | } |
||
| 73 |