/** * Sets the value of the property. Expected to be a URL. * @param string $value The URL value to set. * @return \EVought\vCardTools\DataPropertyBuilder * @throws \DomainException If the URL value is not well-formed. * @see https://tools.ietf.org/html/rfc6350#section-5.7 */ public function setValue($value) { \assert(null !== $value); $url = \filter_var($value, \FILTER_VALIDATE_URL); if (false === $url && false == DataUri::isParsable($value)) { throw new \DomainException($value . ' is not a valid url.'); } else { $this->value = $value; } return $this; }
/** * @group default * @depends testStoreAndRetrieveVCard */ public function testStoreAndRetrieveWLogoDataMediaType(VCardDB $vcardDB) { $this->checkRowCounts(['CONTACT' => 0, 'CONTACT_ORG' => 0, 'CONTACT_DATA' => 0]); $expected = ['org_name' => 'Seinar Fleet Systems', 'org_unit1' => 'Seinar Advanced Projects Laboratory', 'org_unit2' => 'TIE AO1X Division', 'fn' => 'Seinar APL TIE AO1X Division', 'logo' => '|-0-|']; $vcard = new VCard(); $dataUri = new DataUri('image/example', $expected['logo'], DataUri::ENCODING_BASE64); VCard::builder('fn')->setValue($expected['fn'])->pushTo($vcard); VCard::builder('org')->setField('Name', $expected['org_name'])->setField('Unit1', $expected['org_unit1'])->setField('Unit2', $expected['org_unit2'])->pushTo($vcard); VCard::builder('logo')->setValue($dataUri->toString())->setMediaType('image/example')->pushTo($vcard); $contactID = $vcardDB->store($vcard); $this->checkRowCounts(['CONTACT' => 1, 'CONTACT_ORG' => 1, 'CONTACT_DATA' => 1], $vcard); $resultVCard = $vcardDB->fetchOne($contactID); $this->compareVCards($vcard, $resultVCard); }