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 |
||
| 23 | class AdminExtension extends Twig_Extension |
||
| 24 | { |
||
| 25 | use StringUtilTrait; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var ApplicationConfiguration |
||
| 29 | */ |
||
| 30 | private $applicationConfiguration; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var MenuFactory |
||
| 34 | */ |
||
| 35 | private $menuFactory; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var Twig_Environment |
||
| 39 | */ |
||
| 40 | private $twig; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var RouterInterface |
||
| 44 | */ |
||
| 45 | private $router; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var TranslatorInterface |
||
| 49 | */ |
||
| 50 | private $translator; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var ConfigurationFactory |
||
| 54 | */ |
||
| 55 | private $configurationFactory; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * AdminExtension constructor. |
||
| 59 | * |
||
| 60 | * @param ApplicationConfigurationStorage $applicationConfigurationStorage |
||
| 61 | * @param MenuFactory $menuFactory |
||
| 62 | * @param Twig_Environment $twig |
||
| 63 | * @param RouterInterface $router |
||
| 64 | * @param TranslatorInterface $translator |
||
| 65 | * @param ConfigurationFactory $configurationFactory |
||
| 66 | */ |
||
| 67 | public function __construct( |
||
| 82 | |||
| 83 | public function getFunctions() |
||
| 96 | |||
| 97 | public function getApplicationParameter($name) |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Render a menu according to given name. |
||
| 104 | * |
||
| 105 | * @param string $name |
||
| 106 | * @param ViewInterface|null $view |
||
| 107 | * |
||
| 108 | * @return string |
||
| 109 | */ |
||
| 110 | public function getMenu(string $name, ViewInterface $view = null) |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Return true if a menu with the given name exists. |
||
| 122 | * |
||
| 123 | * @param string $name |
||
| 124 | * |
||
| 125 | * @return bool |
||
| 126 | */ |
||
| 127 | public function hasMenu(string $name) |
||
| 131 | |||
| 132 | /** |
||
| 133 | * Return the url of an menu item. |
||
| 134 | * |
||
| 135 | * @param MenuItemConfiguration $configuration |
||
| 136 | * @param ViewInterface $view |
||
| 137 | * |
||
| 138 | * @return string |
||
| 139 | * |
||
| 140 | * @throws Exception |
||
| 141 | */ |
||
| 142 | public function getMenuAction(MenuItemConfiguration $configuration, ViewInterface $view = null) |
||
| 179 | |||
| 180 | /** |
||
| 181 | * @param FieldInterface $field |
||
| 182 | * @return string |
||
| 183 | * |
||
| 184 | * @throws Exception |
||
| 185 | */ |
||
| 186 | public function getFieldHeader(FieldInterface $field) |
||
| 206 | |||
| 207 | /** |
||
| 208 | * Render a field of an entity. |
||
| 209 | * |
||
| 210 | * @param FieldInterface $field |
||
| 211 | * @param $entity |
||
| 212 | * |
||
| 213 | * @return string |
||
| 214 | */ |
||
| 215 | public function getField(FieldInterface $field, $entity) |
||
| 233 | |||
| 234 | /** |
||
| 235 | * Return the url of an Admin action. |
||
| 236 | * |
||
| 237 | * @param ViewInterface $view |
||
| 238 | * @param string $actionName |
||
| 239 | * @param mixed|null $entity |
||
| 240 | * |
||
| 241 | * @return string |
||
| 242 | * |
||
| 243 | * @throws Exception |
||
| 244 | */ |
||
| 245 | public function getAdminUrl(ViewInterface $view, string $actionName, $entity = null) |
||
| 274 | |||
| 275 | /** |
||
| 276 | * Return true if the given action is allowed for the given Admin. |
||
| 277 | * |
||
| 278 | * @param ViewInterface $view |
||
| 279 | * @param string $actionName |
||
| 280 | * |
||
| 281 | * @return bool |
||
| 282 | */ |
||
| 283 | public function isAdminActionAllowed(ViewInterface $view, string $actionName) |
||
| 289 | } |
||
| 290 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.