Code Duplication    Length = 12-13 lines in 2 locations

src/Pdp/PunycodeWrapper.php 2 locations

@@ 38-50 (lines=13) @@
35
   *
36
   * @return string Punycode representation in ASCII
37
   */
38
  public function encode($input)
39
  {
40
    if ($this->idnSupport === true) {
41
      // https://git.ispconfig.org/ispconfig/ispconfig3/blob/master/interface/lib/classes/functions.inc.php#L305
42
      if(defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_ASCII')) {
43
        return idn_to_ascii($input, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
44
      } else {
45
        return idn_to_ascii($input);
46
      }
47
    }
48
49
    return self::$punycode->encode($input);
50
  }
51
52
  /**
53
   * Decode a Punycode domain name to its Unicode counterpart
@@ 59-70 (lines=12) @@
56
   *
57
   * @return string Unicode domain name
58
   */
59
  public function decode($input)
60
  {
61
    if ($this->idnSupport === true) {
62
      if(defined('IDNA_NONTRANSITIONAL_TO_UNICODE') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_UNICODE')) {
63
        return idn_to_utf8($input, IDNA_NONTRANSITIONAL_TO_UNICODE, INTL_IDNA_VARIANT_UTS46);
64
      } else {
65
        return idn_to_utf8($input);
66
      }
67
    }
68
69
    return self::$punycode->decode($input);
70
  }
71
}
72