public function testMergingTextDomainsWithPluralRules() { $domainA = new TextDomain(); $domainB = new TextDomain(); $domainA->merge($domainB); $this->assertFalse($domainA->hasPluralRule()); $this->assertFalse($domainB->hasPluralRule()); }
/** * Merge another text domain with the current one. * * The plural rule of both text domains must be compatible for a successful * merge. We are only validating the number of plural forms though, as the * same rule could be made up with different expression. * * @param TextDomain $textDomain * @return TextDomain * @throws Exception\RuntimeException */ public function merge(TextDomain $textDomain) { if ($this->hasPluralRule() && $textDomain->hasPluralRule()) { if ($this->getPluralRule()->getNumPlurals() !== $textDomain->getPluralRule()->getNumPlurals()) { throw new Exception\RuntimeException('Plural rule of merging text domain is not compatible with the current one'); } } elseif ($textDomain->hasPluralRule()) { $this->setPluralRule($textDomain->getPluralRule()); } $this->exchangeArray(array_replace($this->getArrayCopy(), $textDomain->getArrayCopy())); return $this; }