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  | 
            ||
| 11 | class Collection extends Field implements EntityFieldInterface  | 
            ||
| 12 | { | 
            ||
| 13 | /**  | 
            ||
| 14 | * @var Twig_Environment  | 
            ||
| 15 | */  | 
            ||
| 16 | protected $twig;  | 
            ||
| 17 | |||
| 18 | /**  | 
            ||
| 19 | * @var Field[]  | 
            ||
| 20 | */  | 
            ||
| 21 | protected $fields = [];  | 
            ||
| 22 | |||
| 23 | /**  | 
            ||
| 24 | * @var Object  | 
            ||
| 25 | */  | 
            ||
| 26 | protected $entity;  | 
            ||
| 27 | |||
| 28 | /**  | 
            ||
| 29 | * @param mixed $value  | 
            ||
| 30 | * @return string  | 
            ||
| 31 | */  | 
            ||
| 32 | public function render($value)  | 
            ||
| 55 | |||
| 56 | /**  | 
            ||
| 57 | * @param OptionsResolver $resolver  | 
            ||
| 58 | * @return void  | 
            ||
| 59 | */  | 
            ||
| 60 | public function configureOptions(OptionsResolver $resolver)  | 
            ||
| 66 | |||
| 67 | /**  | 
            ||
| 68 | * Set options values after options resolving.  | 
            ||
| 69 | *  | 
            ||
| 70 | * @param array $options  | 
            ||
| 71 | *  | 
            ||
| 72 | * @return mixed  | 
            ||
| 73 | */  | 
            ||
| 74 | public function setOptions(array $options)  | 
            ||
| 78 | |||
| 79 | public function getType()  | 
            ||
| 83 | |||
| 84 | public function setTwig(Twig_Environment $twig)  | 
            ||
| 88 | |||
| 89 | public function setEntity($entity)  | 
            ||
| 93 | }  | 
            ||
| 94 |