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 CreateUser extends Command |
||
9 | { |
||
10 | /** |
||
11 | * The name and signature of the console command. |
||
12 | * |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $signature = 'tenant:create-user {--fake}'; |
||
16 | |||
17 | /** |
||
18 | * The console command description. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $description = 'Create a new user with the option to assign to tenants'; |
||
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() |
||
61 | |||
62 | /** |
||
63 | * Setup a fake user using faker |
||
64 | * |
||
65 | * @return void |
||
66 | */ |
||
67 | private function createFakeUser() |
||
98 | |||
99 | /** |
||
100 | * Create a new user with user supplied input for the users settings |
||
101 | * |
||
102 | * @return void |
||
103 | */ |
||
104 | private function createNewUser() |
||
140 | } |
||
141 |
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.