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 |
||
| 16 | class Organizations extends Api |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * Default permissions level |
||
| 20 | * |
||
| 21 | * @var array |
||
| 22 | */ |
||
| 23 | protected $permission_level = ['read' => '#organization:read', 'edit' => '#organization:edit']; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Organization details (permission needed: #organization:read) |
||
| 27 | * Get information about a specific organization that you are a member of |
||
| 28 | * |
||
| 29 | * @param string $identifier |
||
| 30 | */ |
||
| 31 | public function organization($identifier) |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Update organization (permission needed: #organization:edit) |
||
| 38 | * Update an existing Organization |
||
| 39 | * |
||
| 40 | * @param string|null $identifier |
||
| 41 | * @param string|null $name Organization Name |
||
| 42 | */ |
||
| 43 | public function update($identifier = null, $name = null) |
||
| 51 | } |
||
| 52 |