| Conditions | 3 |
| Paths | 3 |
| Total Lines | 29 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 23 | public function getReverseDNS($address) |
||
| 24 | { |
||
| 25 | $address = trim($address); |
||
| 26 | |||
| 27 | // lets look in our cache database first. |
||
| 28 | $rDns = RDnsCache::getByAddress($address, $this->database); |
||
| 29 | |||
| 30 | if ($rDns instanceof RDnsCache) { |
||
| 31 | // touch cache timer |
||
| 32 | $rDns->save(); |
||
| 33 | |||
| 34 | return $rDns->getData(); |
||
| 35 | } |
||
| 36 | |||
| 37 | // OK, it's not there, let's do an rDNS lookup. |
||
| 38 | $result = @ gethostbyaddr($address); |
||
| 39 | |||
| 40 | View Code Duplication | if ($result !== false) { |
|
|
|
|||
| 41 | $rDns = new RDnsCache(); |
||
| 42 | $rDns->setDatabase($this->database); |
||
| 43 | $rDns->setAddress($address); |
||
| 44 | $rDns->setData($result); |
||
| 45 | $rDns->save(); |
||
| 46 | |||
| 47 | return $result; |
||
| 48 | } |
||
| 49 | |||
| 50 | return null; |
||
| 51 | } |
||
| 52 | } |
||
| 53 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.