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 |
||
| 22 | class IntegrationTest extends ProviderIntegrationTest |
||
| 23 | { |
||
| 24 | protected $skippedTests = [ |
||
| 25 | ]; |
||
| 26 | |||
| 27 | protected $testAddress = false; |
||
| 28 | protected $testReverse = false; |
||
| 29 | protected $testIpv6 = false; |
||
| 30 | protected $testHttpProvider = false; |
||
| 31 | |||
| 32 | public static function setUpBeforeClass() |
||
| 33 | { |
||
| 34 | if (false == function_exists('geoip_open')) { |
||
| 35 | self::markTestSkipped('The maxmind\'s official lib required to run these tests.'); |
||
| 36 | } |
||
| 37 | |||
| 38 | if (false == function_exists('GeoIP_record_by_addr')) { |
||
| 39 | self::markTestSkipped('The maxmind\'s official lib required to run these tests.'); |
||
| 40 | } |
||
| 41 | |||
| 42 | parent::setUpBeforeClass(); |
||
| 43 | } |
||
| 44 | |||
| 45 | protected function createProvider(HttpClient $httpClient) |
||
| 46 | { |
||
| 47 | return new MaxMindBinary(__DIR__.'/fixtures/GeoLiteCity.dat'); |
||
| 48 | } |
||
| 49 | |||
| 50 | protected function getCacheDir() |
||
| 51 | { |
||
| 52 | return __DIR__.'/.cached_responses'; |
||
| 53 | } |
||
| 54 | |||
| 55 | protected function getApiKey() |
||
| 56 | { |
||
| 57 | return null; |
||
| 58 | } |
||
| 59 | } |
||
| 60 |