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 | View Code Duplication | class CallActivityListProvider implements ActivityListProviderInterface, CommentProviderInterface |
|
| 17 | { |
||
| 18 | const ACTIVITY_CLASS = 'OroCRM\Bundle\CallBundle\Entity\Call'; |
||
| 19 | const ACL_CLASS = 'OroCRM\Bundle\CallBundle\Entity\Call'; |
||
| 20 | |||
| 21 | /** @var DoctrineHelper */ |
||
| 22 | protected $doctrineHelper; |
||
| 23 | |||
| 24 | /** @var ServiceLink */ |
||
| 25 | protected $entityOwnerAccessorLink; |
||
| 26 | |||
| 27 | /** @var ActivityAssociationHelper */ |
||
| 28 | protected $activityAssociationHelper; |
||
| 29 | |||
| 30 | /** @var CommentAssociationHelper */ |
||
| 31 | protected $commentAssociationHelper; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param DoctrineHelper $doctrineHelper |
||
| 35 | * @param ServiceLink $entityOwnerAccessorLink |
||
| 36 | * @param ActivityAssociationHelper $activityAssociationHelper |
||
| 37 | * @param CommentAssociationHelper $commentAssociationHelper |
||
| 38 | */ |
||
| 39 | public function __construct( |
||
| 50 | |||
| 51 | /** |
||
| 52 | * {@inheritdoc} |
||
| 53 | */ |
||
| 54 | public function isApplicableTarget($entityClass, $accessible = true) |
||
| 62 | |||
| 63 | /** |
||
| 64 | * {@inheritdoc} |
||
| 65 | */ |
||
| 66 | public function getSubject($entity) |
||
| 71 | |||
| 72 | /** |
||
| 73 | * {@inheritdoc} |
||
| 74 | */ |
||
| 75 | public function getDescription($entity) |
||
| 80 | |||
| 81 | /** |
||
| 82 | * {@inheritdoc} |
||
| 83 | */ |
||
| 84 | public function getData(ActivityList $activityListEntity) |
||
| 88 | |||
| 89 | /** |
||
| 90 | * {@inheritdoc} |
||
| 91 | */ |
||
| 92 | public function getOrganization($activityEntity) |
||
| 97 | |||
| 98 | /** |
||
| 99 | * {@inheritdoc} |
||
| 100 | */ |
||
| 101 | public function getTemplate() |
||
| 105 | |||
| 106 | /** |
||
| 107 | * {@inheritdoc} |
||
| 108 | */ |
||
| 109 | public function getRoutes() |
||
| 117 | |||
| 118 | /** |
||
| 119 | * {@inheritdoc} |
||
| 120 | */ |
||
| 121 | public function getActivityClass() |
||
| 125 | |||
| 126 | /** |
||
| 127 | * {@inheritdoc} |
||
| 128 | */ |
||
| 129 | public function getAclClass() |
||
| 133 | |||
| 134 | /** |
||
| 135 | * {@inheritdoc} |
||
| 136 | */ |
||
| 137 | public function getActivityId($entity) |
||
| 141 | |||
| 142 | /** |
||
| 143 | * {@inheritdoc} |
||
| 144 | */ |
||
| 145 | public function isApplicable($entity) |
||
| 153 | |||
| 154 | /** |
||
| 155 | * {@inheritdoc} |
||
| 156 | */ |
||
| 157 | public function getTargetEntities($entity) |
||
| 161 | |||
| 162 | /** |
||
| 163 | * {@inheritdoc} |
||
| 164 | */ |
||
| 165 | public function isCommentsEnabled($entityClass) |
||
| 169 | |||
| 170 | /** |
||
| 171 | * {@inheritdoc} |
||
| 172 | */ |
||
| 173 | public function getActivityOwners($entity, ActivityList $activityList) |
||
| 188 | } |
||
| 189 |