Code Duplication    Length = 12-13 lines in 2 locations

src/Pdp/PunycodeWrapper.php 2 locations

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