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 SiteConfigSubsites extends DataExtension |
||
| 18 | { |
||
| 19 | private static $has_one = [ |
||
|
|
|||
| 20 | 'Subsite' => Subsite::class, // The subsite that this page belongs to |
||
| 21 | ]; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Update any requests to limit the results to the current site |
||
| 25 | * @param SQLSelect $query |
||
| 26 | * @param DataQuery|null $dataQuery |
||
| 27 | */ |
||
| 28 | public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null) |
||
| 58 | |||
| 59 | public function onBeforeWrite() |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Return a piece of text to keep DataObject cache keys appropriately specific |
||
| 68 | */ |
||
| 69 | public function cacheKeyComponent() |
||
| 73 | |||
| 74 | public function updateCMSFields(FieldList $fields) |
||
| 78 | } |
||
| 79 |
This check marks private properties in classes that are never used. Those properties can be removed.