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 |
||
| 31 | class User extends \Sabre\CalDAV\Principal\User { |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Returns a list of ACE's for this node. |
||
| 35 | * |
||
| 36 | * Each ACE has the following properties: |
||
| 37 | * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
||
| 38 | * currently the only supported privileges |
||
| 39 | * * 'principal', a url to the principal who owns the node |
||
| 40 | * * 'protected' (optional), indicating that this ACE is not allowed to |
||
| 41 | * be updated. |
||
| 42 | * |
||
| 43 | * @return array |
||
| 44 | */ |
||
| 45 | View Code Duplication | function getACL() { |
|
| 54 | |||
| 55 | } |
||
| 56 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.