Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 18 | class PageVarExtension extends \Twig_Extension |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @var TranslatorInterface |
||
| 22 | */ |
||
| 23 | private $translator; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var ParameterBag |
||
| 27 | */ |
||
| 28 | private $pageVars; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @var LoggerInterface |
||
| 32 | * @deprecated - remove at Core-2.0 |
||
| 33 | */ |
||
| 34 | private $logger; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var AssetExtension |
||
| 38 | * @deprecated - remove at Core-2.0 |
||
| 39 | */ |
||
| 40 | private $assetExtension; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * PageVarExtension constructor. |
||
| 44 | * @param TranslatorInterface $translator |
||
| 45 | * @param ParameterBag $pageVars |
||
| 46 | * @param LoggerInterface $logger |
||
| 47 | * @param AssetExtension $assetExtension |
||
| 48 | */ |
||
| 49 | public function __construct( |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Returns a list of functions to add to the existing list. |
||
| 63 | * |
||
| 64 | * @return array An array of functions |
||
| 65 | */ |
||
| 66 | public function getFunctions() |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @deprecated at Core 1.4.1, remove at Core-2.0 |
||
| 77 | * @see use pageSetVar() or pageAddAsset() |
||
| 78 | * @param string $name |
||
| 79 | * @param string $value |
||
| 80 | */ |
||
| 81 | public function pageAddVar($name, $value) |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Zikula imposes no restriction on page variable names. |
||
| 93 | * Typical usage is to set `title` `meta.charset` `lang` etc. |
||
| 94 | * array values are set using `.` in the `$name` string (e.g. `meta.charset`) |
||
| 95 | * @param string $name |
||
| 96 | * @param string $value |
||
| 97 | */ |
||
| 98 | View Code Duplication | public function pageSetVar($name, $value) |
|
| 106 | |||
| 107 | /** |
||
| 108 | * @param $name |
||
| 109 | * @param null $default |
||
| 110 | * @return mixed |
||
| 111 | */ |
||
| 112 | View Code Duplication | public function pageGetVar($name, $default = null) |
|
| 120 | } |
||
| 121 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.