| 1 | <?php |
||
| 18 | trait HeaderCommonMethods |
||
| 19 | { |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Gets header filed name |
||
| 23 | * |
||
| 24 | * @return string |
||
| 25 | */ |
||
| 26 | 22 | public function getName() |
|
| 30 | |||
| 31 | /** |
||
| 32 | * Sets the header field name |
||
| 33 | * |
||
| 34 | * @param string $name |
||
| 35 | * |
||
| 36 | * @return AbstractHeader|$this|self |
||
| 37 | */ |
||
| 38 | 16 | public function setName($name) |
|
| 43 | |||
| 44 | /** |
||
| 45 | * Gets header value |
||
| 46 | * |
||
| 47 | * @return string |
||
| 48 | */ |
||
| 49 | 12 | public function getValue() |
|
| 53 | |||
| 54 | /** |
||
| 55 | * Sets the header value |
||
| 56 | * |
||
| 57 | * @param string $value |
||
| 58 | * |
||
| 59 | * @return AbstractHeader|$this|self |
||
| 60 | */ |
||
| 61 | 16 | public function setValue($value) |
|
| 66 | |||
| 67 | /** |
||
| 68 | * Returns the string version of this header |
||
| 69 | * |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | abstract public function toString(); |
||
| 73 | |||
| 74 | /** |
||
| 75 | * An automated version of toString() method |
||
| 76 | * |
||
| 77 | * @return string |
||
| 78 | */ |
||
| 79 | 16 | public function __toString() |
|
| 83 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: