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  | 
            ||
| 35 | abstract class Base implements IProvider { | 
            ||
| 36 | |||
| 37 | /** @var IUserManager */  | 
            ||
| 38 | protected $userManager;  | 
            ||
| 39 | |||
| 40 | /** @var string[] */  | 
            ||
| 41 | protected $userDisplayNames = [];  | 
            ||
| 42 | |||
| 43 | /** @var IGroupManager */  | 
            ||
| 44 | protected $groupManager;  | 
            ||
| 45 | |||
| 46 | /** @var string[] */  | 
            ||
| 47 | protected $groupDisplayNames = [];  | 
            ||
| 48 | |||
| 49 | /**  | 
            ||
| 50 | * @param IUserManager $userManager  | 
            ||
| 51 | * @param IGroupManager $groupManager  | 
            ||
| 52 | */  | 
            ||
| 53 | 	public function __construct(IUserManager $userManager, IGroupManager $groupManager) { | 
            ||
| 57 | |||
| 58 | /**  | 
            ||
| 59 | * @param IEvent $event  | 
            ||
| 60 | * @param string $subject  | 
            ||
| 61 | * @param array $parameters  | 
            ||
| 62 | */  | 
            ||
| 63 | View Code Duplication | 	protected function setSubjects(IEvent $event, $subject, array $parameters) { | 
            |
| 73 | |||
| 74 | /**  | 
            ||
| 75 | * @param array $eventData  | 
            ||
| 76 | * @return array  | 
            ||
| 77 | */  | 
            ||
| 78 | 	protected function generateObjectParameter($eventData) { | 
            ||
| 89 | |||
| 90 | /**  | 
            ||
| 91 | * @param array $data  | 
            ||
| 92 | * @param IL10N $l  | 
            ||
| 93 | * @return array  | 
            ||
| 94 | */  | 
            ||
| 95 | 	protected function generateCalendarParameter($data, IL10N $l) { | 
            ||
| 111 | |||
| 112 | /**  | 
            ||
| 113 | * @param int $id  | 
            ||
| 114 | * @param string $name  | 
            ||
| 115 | * @return array  | 
            ||
| 116 | */  | 
            ||
| 117 | 	protected function generateLegacyCalendarParameter($id, $name) { | 
            ||
| 124 | |||
| 125 | /**  | 
            ||
| 126 | * @param string $uid  | 
            ||
| 127 | * @return array  | 
            ||
| 128 | */  | 
            ||
| 129 | 	protected function generateUserParameter($uid) { | 
            ||
| 140 | |||
| 141 | /**  | 
            ||
| 142 | * @param string $uid  | 
            ||
| 143 | * @return string  | 
            ||
| 144 | */  | 
            ||
| 145 | 	protected function getUserDisplayName($uid) { | 
            ||
| 152 | |||
| 153 | /**  | 
            ||
| 154 | * @param string $gid  | 
            ||
| 155 | * @return array  | 
            ||
| 156 | */  | 
            ||
| 157 | View Code Duplication | 	protected function generateGroupParameter($gid) { | 
            |
| 168 | |||
| 169 | /**  | 
            ||
| 170 | * @param string $gid  | 
            ||
| 171 | * @return string  | 
            ||
| 172 | */  | 
            ||
| 173 | 	protected function getGroupDisplayName($gid) { | 
            ||
| 180 | }  | 
            ||
| 181 |