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 |
||
| 12 | View Code Duplication | class UseCaseFeatureContext implements \Behat\Behat\Context\Context |
|
| 13 | { |
||
| 14 | /** @var UseCase */ |
||
| 15 | private $useCase; |
||
| 16 | |||
| 17 | /** @var DomainRepositoryInterface */ |
||
| 18 | private $domainRepository; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * UseCaseFeatureContext constructor. |
||
| 22 | * |
||
| 23 | * @param UseCase $useCase |
||
| 24 | * @param DomainRepositoryInterface $domainRepository |
||
| 25 | */ |
||
| 26 | public function __construct(UseCase $useCase, DomainRepositoryInterface $domainRepository) |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @When I create usecase with :arg1 and type :arg2 id for :arg3 domain |
||
| 34 | */ |
||
| 35 | public function iCreateUsecaseWithIdForDomain($arg1, $arg2, $arg3) |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @Then I should see new usecase in :arg1 domain |
||
| 47 | */ |
||
| 48 | public function iShouldSeeNewUsecaseInDomain($arg1) |
||
| 60 | } |
||
| 61 |
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.