Skip to content

Commit 17cc8b1

Browse files
committed
fix #234 replace mutable setter with method that return new instance
1 parent f0f9be9 commit 17cc8b1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/Domain.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ public function __construct(
124124
int $asciiIDNAOption = IDNA_DEFAULT,
125125
int $unicodeIDNAOption = IDNA_DEFAULT
126126
) {
127-
$this->setIDNAOptions($asciiIDNAOption, $unicodeIDNAOption);
127+
$this->asciiIDNAOption = $asciiIDNAOption;
128+
$this->unicodeIDNAOption = $unicodeIDNAOption;
128129
$this->labels = $this->setLabels($domain, $asciiIDNAOption, $unicodeIDNAOption);
129130
if ([] !== $this->labels) {
130131
$this->domain = implode('.', array_reverse($this->labels));
@@ -748,11 +749,9 @@ public function getUnicodeIDNAOption(): int
748749
* @param int $forUnicode
749750
* @return $this
750751
*/
751-
public function setIDNAOptions(int $forAscii, int $forUnicode)
752+
public function withIDNAOptions(int $forAscii, int $forUnicode)
752753
{
753-
$this->asciiIDNAOption = $forAscii;
754-
$this->unicodeIDNAOption = $forUnicode;
755-
return $this;
754+
return new self($this->domain, $this->publicSuffix, $forAscii, $forUnicode);
756755
}
757756

758757
/**

0 commit comments

Comments
 (0)