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 |
||
| 8 | class Brand extends \Hautelook\AliceBundle\Tests\SymfonyApp\TestBundle\Entity\Brand implements \Doctrine\ORM\Proxy\Proxy |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with |
||
| 12 | * three parameters, being respectively the proxy object to be initialized, the method that triggered the |
||
| 13 | * initialization process and an array of ordered parameters that were passed to that method. |
||
| 14 | * |
||
| 15 | * @see \Doctrine\Common\Persistence\Proxy::__setInitializer |
||
| 16 | */ |
||
| 17 | public $__initializer__; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var \Closure the callback responsible of loading properties that need to be copied in the cloned object |
||
| 21 | * |
||
| 22 | * @see \Doctrine\Common\Persistence\Proxy::__setCloner |
||
| 23 | */ |
||
| 24 | public $__cloner__; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var boolean flag indicating if this object was already initialized |
||
| 28 | * |
||
| 29 | * @see \Doctrine\Common\Persistence\Proxy::__isInitialized |
||
| 30 | */ |
||
| 31 | public $__isInitialized__ = false; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var array properties to be lazy loaded, with keys being the property |
||
| 35 | * names and values being their default values |
||
| 36 | * |
||
| 37 | * @see \Doctrine\Common\Persistence\Proxy::__getLazyProperties |
||
| 38 | */ |
||
| 39 | public static $lazyPropertiesDefaults = ['canonicalName' => NULL]; |
||
| 40 | |||
| 41 | |||
| 42 | |||
| 43 | /** |
||
| 44 | * @param \Closure $initializer |
||
| 45 | * @param \Closure $cloner |
||
| 46 | */ |
||
| 47 | public function __construct($initializer = null, $cloner = null) |
||
| 54 | |||
| 55 | /** |
||
| 56 | * |
||
| 57 | * @param string $name |
||
| 58 | */ |
||
| 59 | public function __get($name) |
||
| 69 | |||
| 70 | /** |
||
| 71 | * |
||
| 72 | * @param string $name |
||
| 73 | * @param mixed $value |
||
| 74 | */ |
||
| 75 | public function __set($name, $value) |
||
| 87 | |||
| 88 | /** |
||
| 89 | * |
||
| 90 | * @param string $name |
||
| 91 | * @return boolean |
||
| 92 | */ |
||
| 93 | public function __isset($name) |
||
| 103 | |||
| 104 | /** |
||
| 105 | * |
||
| 106 | * @return array |
||
| 107 | */ |
||
| 108 | public function __sleep() |
||
| 116 | |||
| 117 | /** |
||
| 118 | * |
||
| 119 | */ |
||
| 120 | public function __wakeup() |
||
| 139 | |||
| 140 | /** |
||
| 141 | * |
||
| 142 | */ |
||
| 143 | public function __clone() |
||
| 147 | |||
| 148 | /** |
||
| 149 | * Forces initialization of the proxy |
||
| 150 | */ |
||
| 151 | public function __load() |
||
| 155 | |||
| 156 | /** |
||
| 157 | * {@inheritDoc} |
||
| 158 | * @internal generated method: use only when explicitly handling proxy specific loading logic |
||
| 159 | */ |
||
| 160 | public function __isInitialized() |
||
| 164 | |||
| 165 | /** |
||
| 166 | * {@inheritDoc} |
||
| 167 | * @internal generated method: use only when explicitly handling proxy specific loading logic |
||
| 168 | */ |
||
| 169 | public function __setInitialized($initialized) |
||
| 173 | |||
| 174 | /** |
||
| 175 | * {@inheritDoc} |
||
| 176 | * @internal generated method: use only when explicitly handling proxy specific loading logic |
||
| 177 | */ |
||
| 178 | public function __setInitializer(\Closure $initializer = null) |
||
| 182 | |||
| 183 | /** |
||
| 184 | * {@inheritDoc} |
||
| 185 | * @internal generated method: use only when explicitly handling proxy specific loading logic |
||
| 186 | */ |
||
| 187 | public function __getInitializer() |
||
| 191 | |||
| 192 | /** |
||
| 193 | * {@inheritDoc} |
||
| 194 | * @internal generated method: use only when explicitly handling proxy specific loading logic |
||
| 195 | */ |
||
| 196 | public function __setCloner(\Closure $cloner = null) |
||
| 200 | |||
| 201 | /** |
||
| 202 | * {@inheritDoc} |
||
| 203 | * @internal generated method: use only when explicitly handling proxy specific cloning logic |
||
| 204 | */ |
||
| 205 | public function __getCloner() |
||
| 209 | |||
| 210 | /** |
||
| 211 | * {@inheritDoc} |
||
| 212 | * @internal generated method: use only when explicitly handling proxy specific loading logic |
||
| 213 | * @static |
||
| 214 | */ |
||
| 215 | public function __getLazyProperties() |
||
| 219 | |||
| 220 | |||
| 221 | /** |
||
| 222 | * {@inheritDoc} |
||
| 223 | */ |
||
| 224 | public function getId() |
||
| 235 | |||
| 236 | /** |
||
| 237 | * {@inheritDoc} |
||
| 238 | */ |
||
| 239 | public function getName() |
||
| 246 | |||
| 247 | /** |
||
| 248 | * {@inheritDoc} |
||
| 249 | */ |
||
| 250 | public function getProducts() |
||
| 257 | |||
| 258 | } |
||
| 259 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.