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 FloatToIntCastByRoundDownscaleFilterLoaderTest extends AbstractTest |
||
| 17 | { |
||
| 18 | public function testLoad() |
||
| 19 | { |
||
| 20 | $loader = new DownscaleFilterLoader(); |
||
| 21 | $imagine = new Imagine(); |
||
| 22 | $image = $imagine->open(__DIR__.'/../../../Fixtures/assets/square-300x300.png'); |
||
| 23 | |||
| 24 | $options = array( |
||
| 25 | 'max' => array(201, 201), |
||
| 26 | ); |
||
| 27 | |||
| 28 | $image = $loader->load($image, $options); |
||
| 29 | $size = $image->getSize(); |
||
| 30 | |||
| 31 | $this->assertEquals($options['max'], array($size->getWidth(), $size->getHeight())); |
||
| 32 | } |
||
| 33 | } |
||
| 34 |