| Conditions | 5 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public static function hamming($a, $b) |
||
| 18 | { |
||
| 19 | if (!is_string($a) || !is_string($b) || (strlen($a) !== strlen($b))) { |
||
| 20 | return false; |
||
| 21 | } |
||
| 22 | static $distance = 0; |
||
| 23 | static $previous = array(); |
||
| 24 | if (array($a, $b) === $previous) { |
||
| 25 | return $distance; |
||
| 26 | } |
||
| 27 | $previous = array($a, $b); |
||
| 28 | $a = self::split($a); |
||
| 29 | $b = self::split($b); |
||
| 30 | $distance = count(array_diff_assoc((array) $a, (array) $b)); |
||
| 31 | return $distance; |
||
| 32 | } |
||
| 37 |