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 |
||
| 29 | class CalendarImpl implements ICalendar { |
||
| 30 | |||
| 31 | /** @var CalDavBackend */ |
||
| 32 | private $backend; |
||
| 33 | |||
| 34 | /** @var Calendar */ |
||
| 35 | private $calendar; |
||
| 36 | |||
| 37 | /** @var array */ |
||
| 38 | private $calendarInfo; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * CalendarImpl constructor. |
||
| 42 | * |
||
| 43 | * @param Calendar $calendar |
||
| 44 | * @param array $calendarInfo |
||
| 45 | * @param CalDavBackend $backend |
||
| 46 | */ |
||
| 47 | public function __construct(Calendar $calendar, array $calendarInfo, |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @return string defining the technical unique key |
||
| 56 | * @since 13.0.0 |
||
| 57 | */ |
||
| 58 | public function getKey() { |
||
| 61 | |||
| 62 | /** |
||
| 63 | * In comparison to getKey() this function returns a human readable (maybe translated) name |
||
| 64 | * @return null|string |
||
| 65 | * @since 13.0.0 |
||
| 66 | */ |
||
| 67 | public function getDisplayName() { |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Calendar color |
||
| 73 | * @return null|string |
||
| 74 | * @since 13.0.0 |
||
| 75 | */ |
||
| 76 | public function getDisplayColor() { |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @param string $pattern which should match within the $searchProperties |
||
| 82 | * @param array $searchProperties defines the properties within the query pattern should match |
||
| 83 | * @param array $options - optional parameters: |
||
| 84 | * ['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]] |
||
| 85 | * @param integer|null $limit - limit number of search results |
||
| 86 | * @param integer|null $offset - offset for paging of search results |
||
| 87 | * @return array an array of events/journals/todos which are arrays of key-value-pairs |
||
| 88 | * @since 13.0.0 |
||
| 89 | */ |
||
| 90 | public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null) { |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @return integer build up using \OCP\Constants |
||
| 97 | * @since 13.0.0 |
||
| 98 | */ |
||
| 99 | View Code Duplication | public function getPermissions() { |
|
| 119 | } |
||
| 120 |