Conditions | 5 |
Paths | 5 |
Total Lines | 16 |
Lines | 16 |
Ratio | 100 % |
Tests | 7 |
CRAP Score | 8.7918 |
Changes | 0 |
1 | <?php |
||
9 | 2 | public function __construct(string $status) { |
|
10 | 1 | switch ($status) { |
|
11 | 2 | case 'SAME_USER': |
|
12 | $this->message = 'user can not accept friend request from himself'; |
||
13 | break; |
||
14 | 2 | case 'WAITING': |
|
15 | 2 | $this->message = 'user can not accept a friend request he sent'; |
|
16 | 2 | break; |
|
17 | case 'NOT_FRIENDS': |
||
18 | $this->message = 'user has no pending friend request from this user'; |
||
19 | break; |
||
20 | case 'FRIENDS': |
||
21 | $this->message = 'users are already friends'; |
||
22 | break; |
||
23 | } |
||
24 | 2 | } |
|
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.