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  | 
            ||
| 24 | class StatusService { | 
            ||
| 25 | |||
| 26 | /**  | 
            ||
| 27 | *  | 
            ||
| 28 | * @var ILogger  | 
            ||
| 29 | */  | 
            ||
| 30 | private $logger;  | 
            ||
| 31 | |||
| 32 | /**  | 
            ||
| 33 | *  | 
            ||
| 34 | * @var String  | 
            ||
| 35 | */  | 
            ||
| 36 | private $userId;  | 
            ||
| 37 | |||
| 38 | /**  | 
            ||
| 39 | *  | 
            ||
| 40 | * @var IL10N  | 
            ||
| 41 | */  | 
            ||
| 42 | private $l10n;  | 
            ||
| 43 | |||
| 44 | /**  | 
            ||
| 45 | *  | 
            ||
| 46 | * @var OcrJobMapper  | 
            ||
| 47 | */  | 
            ||
| 48 | private $jobMapper;  | 
            ||
| 49 | |||
| 50 | /**  | 
            ||
| 51 | *  | 
            ||
| 52 | * @var JobService  | 
            ||
| 53 | */  | 
            ||
| 54 | private $jobService;  | 
            ||
| 55 | |||
| 56 | /**  | 
            ||
| 57 | * StatusService constructor.  | 
            ||
| 58 | *  | 
            ||
| 59 | * @param IL10N $l10n  | 
            ||
| 60 | * @param ILogger $logger  | 
            ||
| 61 | * @param unknown $userId  | 
            ||
| 62 | * @param OcrJobMapper $mapper  | 
            ||
| 63 | * @param JobService $jobService  | 
            ||
| 64 | */  | 
            ||
| 65 | 	public function __construct(IL10N $l10n, ILogger $logger, $userId, OcrJobMapper $mapper, JobService $jobService) { | 
            ||
| 72 | |||
| 73 | /**  | 
            ||
| 74 | * A function which returns the JSONResponse for all required status checks and tasks.  | 
            ||
| 75 | * It will check for already processed, pending and failed ocr tasks and return them as needed.  | 
            ||
| 76 | *  | 
            ||
| 77 | * @codeCoverageIgnore  | 
            ||
| 78 | *  | 
            ||
| 79 | * @return string  | 
            ||
| 80 | */  | 
            ||
| 81 | 	public function getStatus() { | 
            ||
| 104 | |||
| 105 | /**  | 
            ||
| 106 | * Handle the possible thrown Exceptions from all methods of this class.  | 
            ||
| 107 | *  | 
            ||
| 108 | * @param Exception $e  | 
            ||
| 109 | * @throws Exception  | 
            ||
| 110 | * @throws NotFoundException  | 
            ||
| 111 | */  | 
            ||
| 112 | View Code Duplication | 	private function handleException($e) { | 
            |
| 123 | }  | 
            
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..