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 |
||
8 | class NoopTransformerSpec extends ObjectBehavior |
||
9 | { |
||
10 | function it_is_initializable() |
||
11 | { |
||
12 | $this->shouldHaveType('Extraload\Transformer\NoopTransformer'); |
||
13 | } |
||
14 | |||
15 | function it_implements_transformer_interface() |
||
16 | { |
||
17 | $this->shouldImplement('Extraload\Transformer\TransformerInterface'); |
||
18 | } |
||
19 | |||
20 | function it_returns_original_data() |
||
21 | { |
||
22 | $this->transform(['foo', 'bar'])->shouldReturn(['foo', 'bar']); |
||
23 | } |
||
24 | } |
||
25 |