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  | 
            ||
| 17 | class FirewallRule extends AbstractApi  | 
            ||
| 18 | { | 
            ||
| 19 | /**  | 
            ||
| 20 | * List all firewall rules on the current account.  | 
            ||
| 21 | *  | 
            ||
| 22 | * @see https://www.vultr.com/api/#firewall_rule_list  | 
            ||
| 23 | *  | 
            ||
| 24 | * @return FirewallRuleEntity  | 
            ||
| 25 | */  | 
            ||
| 26 | public function list($groupId, $direction, $ipType)  | 
            ||
| 33 | |||
| 34 | /**  | 
            ||
| 35 | * Create a rule in a firewall group.  | 
            ||
| 36 | *  | 
            ||
| 37 | * @param string $groupId Target firewall group  | 
            ||
| 38 | * @param string $direction Direction of rule. Possible values: "in".  | 
            ||
| 39 | * @param string $ipType IP address type. Possible values: "v4", "v6".  | 
            ||
| 40 | * @param string $protocol Protocol type. Possible  | 
            ||
| 41 | * @param string $subnet IP address representing a subnet  | 
            ||
| 42 | * @param int $subnetSize iP prefix size in bits  | 
            ||
| 43 | * @param string $port tCP/UDP only  | 
            ||
| 44 | *  | 
            ||
| 45 | * @throws HttpException  | 
            ||
| 46 | */  | 
            ||
| 47 | public function create(string $groupId, string $direction, string $ipType, string $protocol, string $subnet, int $subnetSize, $port = null)  | 
            ||
| 65 | |||
| 66 | /**  | 
            ||
| 67 | * Delete a rule in a firewall group.  | 
            ||
| 68 | *  | 
            ||
| 69 | * @param string $groupId Firewall group to delete  | 
            ||
| 70 | * @param int $ruleNumber Rule number to delete  | 
            ||
| 71 | *  | 
            ||
| 72 | * @throws HttpException  | 
            ||
| 73 | */  | 
            ||
| 74 | View Code Duplication | public function delete($groupId, $ruleNumber)  | 
            |
| 82 | }  | 
            ||
| 83 |