Conditions | 5 |
Paths | 5 |
Total Lines | 16 |
Lines | 16 |
Ratio | 100 % |
Tests | 15 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
9 | 8 | public function __construct(string $status) { |
|
10 | 4 | switch ($status) { |
|
11 | 8 | case 'SAME_USER': |
|
12 | 2 | $this->message = 'user can not add himself as a friend'; |
|
13 | 2 | break; |
|
14 | 6 | case 'WAITING': |
|
15 | 2 | $this->message = 'user already sent a friend request to this user'; |
|
16 | 2 | break; |
|
17 | 4 | case 'PENDING': |
|
18 | 2 | $this->message = 'user has a pending friend request from this user'; |
|
19 | 2 | break; |
|
20 | 2 | case 'FRIENDS': |
|
21 | 2 | $this->message = 'users are already friends'; |
|
22 | 2 | break; |
|
23 | } |
||
24 | 8 | } |
|
25 | } |
||
26 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.