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 | class ApiHelperTest extends WebTestCase |
||
17 | { |
||
18 | |||
19 | /** @var Container The DI container. */ |
||
20 | protected $container; |
||
21 | |||
22 | /** @var ApiHelper The API Helper object to test. */ |
||
23 | protected $apiHelper; |
||
24 | |||
25 | /** |
||
26 | * Set up the ApiHelper object for testing. |
||
27 | */ |
||
28 | public function setUp() |
||
29 | { |
||
30 | $client = static::createClient(); |
||
31 | $this->container = $client->getContainer(); |
||
32 | $this->apiHelper = new ApiHelper($this->container); |
||
33 | $this->cache = $this->container->get('cache.app'); |
||
34 | } |
||
35 | |||
36 | public function testGroups() |
||
37 | { |
||
38 | // placeholder |
||
39 | } |
||
40 | } |
||
41 |