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 |
||
| 13 | View Code Duplication | class ModelFeatureContext implements \Behat\Behat\Context\Context |
|
| 14 | { |
||
| 15 | /** @var DomainRepository */ |
||
| 16 | private $domainRepository; |
||
| 17 | /** @var UseCase */ |
||
| 18 | private $useCase; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * ModelFeatureContext constructor. |
||
| 22 | * |
||
| 23 | * @param UseCase $useCase |
||
| 24 | * @param DomainRepository $domainRepository |
||
| 25 | */ |
||
| 26 | public function __construct(UseCase $useCase, DomainRepository $domainRepository) |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @When I create model with :arg1 id for :arg2 domain |
||
| 34 | */ |
||
| 35 | public function iCreateModelWithIdForDomain($arg1, $arg2) |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @Then I should see new model in :arg1 domain |
||
| 46 | */ |
||
| 47 | public function iShouldSeeAddedToDomain($arg1) |
||
| 59 | } |
||
| 60 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.