protected function setMediaTypeFromLine(VCardLine $line) { if ($line->hasParameter('mediatype')) { $mediaTypes = $line->getParameter('mediatype'); if (count($mediaTypes) > 1) { throw new Exceptions\MalformedParameterException('Multiple MEDIATYPE parameters supplied for ' . $this->getName()); } else { $this->setMediaType($mediaTypes[0]); } } }
protected function setBuilderFromLine(VCardLine $vcardLine) { \assert($this->getName() === $vcardLine->getName()); $this->group = empty($vcardLine->getGroup()) ? null : $vcardLine->getGroup(); if ($vcardLine->hasParameter('pref')) { if (!$this->getSpecification()->isCardinalityToN()) { throw new \DomainException('PREF not allowed for *1 or 1 cardinality: ' . $this->getName()); } $prefs = $vcardLine->getParameter('pref'); if (count($prefs) > 1) { throw new Exceptions\MalformedParameterException('Multiple PREF parameters provided for : ' . $this->getName()); } else { $this->pref = $prefs[0]; } } if ($vcardLine->hasParameter('value')) { $valueTypes = $vcardLine->getParameter('value'); if (count($valueTypes) != 1) { throw new Exceptions\MalformedParameterException('Muliple VALUE parameters provided for : ' . $this->getName()); } $this->setValueType($valueTypes[0]); } return $this; }