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  | 
            ||
| 42 | class OcmController extends Controller { | 
            ||
| 43 | const API_VERSION = '1.0-proposal1';  | 
            ||
| 44 | |||
| 45 | /**  | 
            ||
| 46 | * @var IURLGenerator  | 
            ||
| 47 | */  | 
            ||
| 48 | protected $urlGenerator;  | 
            ||
| 49 | |||
| 50 | /**  | 
            ||
| 51 | * @var IUserManager  | 
            ||
| 52 | */  | 
            ||
| 53 | protected $userManager;  | 
            ||
| 54 | |||
| 55 | /**  | 
            ||
| 56 | * @var AddressHandler  | 
            ||
| 57 | */  | 
            ||
| 58 | protected $addressHandler;  | 
            ||
| 59 | |||
| 60 | /**  | 
            ||
| 61 | * @var FedShareManager  | 
            ||
| 62 | */  | 
            ||
| 63 | protected $fedShareManager;  | 
            ||
| 64 | |||
| 65 | /**  | 
            ||
| 66 | * @var ILogger  | 
            ||
| 67 | */  | 
            ||
| 68 | protected $logger;  | 
            ||
| 69 | |||
| 70 | /**  | 
            ||
| 71 | * OcmController constructor.  | 
            ||
| 72 | *  | 
            ||
| 73 | * @param string $appName  | 
            ||
| 74 | * @param IRequest $request  | 
            ||
| 75 | * @param IURLGenerator $urlGenerator  | 
            ||
| 76 | * @param IUserManager $userManager  | 
            ||
| 77 | * @param AddressHandler $addressHandler  | 
            ||
| 78 | * @param FedShareManager $fedShareManager  | 
            ||
| 79 | * @param ILogger $logger  | 
            ||
| 80 | */  | 
            ||
| 81 | View Code Duplication | public function __construct($appName,  | 
            |
| 97 | |||
| 98 | /**  | 
            ||
| 99 | * @NoCSRFRequired  | 
            ||
| 100 | * @PublicPage  | 
            ||
| 101 | *  | 
            ||
| 102 | * EndPoint discovery  | 
            ||
| 103 | * Responds to /ocm-provider/ requests  | 
            ||
| 104 | *  | 
            ||
| 105 | * @return array  | 
            ||
| 106 | */  | 
            ||
| 107 | 	public function discovery() { | 
            ||
| 120 | |||
| 121 | /**  | 
            ||
| 122 | * @NoCSRFRequired  | 
            ||
| 123 | * @PublicPage  | 
            ||
| 124 | *  | 
            ||
| 125 | *  | 
            ||
| 126 | *  | 
            ||
| 127 | * @param string $shareWith identifier of the user or group  | 
            ||
| 128 | * to share the resource with  | 
            ||
| 129 | * @param string $name name of the shared resource  | 
            ||
| 130 | * @param string $description share description (optional)  | 
            ||
| 131 | * @param string $providerId Identifier of the resource at the provider side  | 
            ||
| 132 | * @param string $owner identifier of the user that owns the resource  | 
            ||
| 133 | * @param string $ownerDisplayName display name of the owner  | 
            ||
| 134 | * @param string $sender Provider specific identifier of the user that wants  | 
            ||
| 135 | * to share the resource  | 
            ||
| 136 | * @param string $senderDisplayName Display name of the user that wants  | 
            ||
| 137 | * to share the resource  | 
            ||
| 138 | * @param string $shareType Share type (user or group share)  | 
            ||
| 139 | * @param string $resourceType only 'file' is supported atm  | 
            ||
| 140 | * @param array $protocol  | 
            ||
| 141 | * [  | 
            ||
| 142 | * 'name' => (string) protocol name. Only 'webdav' is supported atm,  | 
            ||
| 143 | * 'options' => [  | 
            ||
| 144 | * protocol specific options  | 
            ||
| 145 | * only `webdav` options are supported atm  | 
            ||
| 146 | * e.g. `uri`, `access_token`, `password`, `permissions` etc.  | 
            ||
| 147 | *  | 
            ||
| 148 | * For backward compatibility the webdav protocol will use  | 
            ||
| 149 | * the 'sharedSecret" as username and password  | 
            ||
| 150 | * ]  | 
            ||
| 151 | *  | 
            ||
| 152 | */  | 
            ||
| 153 | public function createShare($shareWith,  | 
            ||
| 243 | |||
| 244 | /**  | 
            ||
| 245 | * @param string $notificationType notification type (SHARE_REMOVED, etc)  | 
            ||
| 246 | * @param string $resourceType only 'file' is supported atm  | 
            ||
| 247 | * @param string $providerId Identifier of the resource at the provider side  | 
            ||
| 248 | * @param array $notification  | 
            ||
| 249 | * [  | 
            ||
| 250 | * optional additional parameters, depending on the notification  | 
            ||
| 251 | * and the resource type  | 
            ||
| 252 | * ]  | 
            ||
| 253 | */  | 
            ||
| 254 | public function processNotification($notificationType,  | 
            ||
| 261 | |||
| 262 | 	protected function getProtocols() { | 
            ||
| 267 | |||
| 268 | /**  | 
            ||
| 269 | * Check if value is null or an array has any null item  | 
            ||
| 270 | *  | 
            ||
| 271 | * @param mixed $param  | 
            ||
| 272 | *  | 
            ||
| 273 | * @return bool  | 
            ||
| 274 | */  | 
            ||
| 275 | View Code Duplication | 	protected function hasNull($param) { | 
            |
| 282 | }  | 
            ||
| 283 | 
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.