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 |
||
8 | class CreateTenant extends Command |
||
9 | { |
||
10 | /** |
||
11 | * The name and signature of the console command. |
||
12 | * |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $signature = 'tenant:create-tenant {--fake}'; |
||
16 | |||
17 | /** |
||
18 | * The console command description. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $description = 'Create a new tenant'; |
||
23 | |||
24 | protected $faker; |
||
25 | |||
26 | /** |
||
27 | * Create a new command instance. |
||
28 | * |
||
29 | * @return void |
||
|
|||
30 | */ |
||
31 | public function __construct(Faker $faker) |
||
37 | |||
38 | /** |
||
39 | * Execute the console command. |
||
40 | * |
||
41 | * @return mixed |
||
42 | */ |
||
43 | public function handle() |
||
58 | |||
59 | /** |
||
60 | * Setup a fake user using faker |
||
61 | * |
||
62 | * @return void |
||
63 | */ |
||
64 | View Code Duplication | private function createFakeTenant() |
|
96 | |||
97 | /** |
||
98 | * Setup a new tenant with user supplied settings for the tenant |
||
99 | * |
||
100 | * @return void |
||
101 | */ |
||
102 | View Code Duplication | private function createNewTenant() |
|
135 | |||
136 | } |
||
137 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.