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 |
||
20 | class GoogleDrive extends Remote |
||
21 | { |
||
22 | /** |
||
23 | * Google api client. |
||
24 | * |
||
25 | * @var \Google_Client |
||
26 | */ |
||
27 | private $client; |
||
28 | |||
29 | /** |
||
30 | * Goole api file id. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | private $fileId; |
||
35 | |||
36 | /** |
||
37 | * Constructor. |
||
38 | * |
||
39 | * @param \Google_Client $client |
||
40 | * @param \Google_Service_Drive_DriveFile $googleFile |
||
41 | */ |
||
42 | View Code Duplication | public function __construct(Google_Client $client, Google_Service_Drive_DriveFile $googleFile) |
|
51 | |||
52 | /** |
||
53 | * Deletes the file. |
||
54 | * |
||
55 | * @throws \phpbu\App\Exception |
||
56 | */ |
||
57 | public function unlink() |
||
66 | } |
||
67 |