Add address
public addAddress ( $name = '', $extended = '', $street = '', $city = '', $region = '', $zip = '', $country = '', $type = 'WORK;POSTAL' ) |
public function testAddress() { $vcard = new VCard(); $vcard->addAddress("Lorem Corp.", "(extended info)", "54th Ipsum Street", "PHPsville", "Guacamole", "01158", "Gitland", 'WORK;POSTAL'); $vcard->addAddress("Wouter Admiraal", "(extended info, again)", "25th Some Address", "Townsville", "Area 51", "045784", "Europe (is a country, right?)", 'WORK;PERSONAL'); $vcard->addAddress("Johannes Admiraal", "(extended info, again, again)", "26th Some Address", "Townsville-South", "Area 51B", "04554", "Europe (no, it isn't)", 'WORK;PERSONAL'); $parser = new VCardParser($vcard->buildVCard()); $this->assertEquals($parser->getCardAtIndex(0)->address['WORK;POSTAL'][0], (object) array('name' => "Lorem Corp.", 'extended' => "(extended info)", 'street' => "54th Ipsum Street", 'city' => "PHPsville", 'region' => "Guacamole", 'zip' => "01158", 'country' => "Gitland")); $this->assertEquals($parser->getCardAtIndex(0)->address['WORK;PERSONAL'][0], (object) array('name' => "Wouter Admiraal", 'extended' => "(extended info, again)", 'street' => "25th Some Address", 'city' => "Townsville", 'region' => "Area 51", 'zip' => "045784", 'country' => "Europe (is a country, right?)")); $this->assertEquals($parser->getCardAtIndex(0)->address['WORK;PERSONAL'][1], (object) array('name' => "Johannes Admiraal", 'extended' => "(extended info, again, again)", 'street' => "26th Some Address", 'city' => "Townsville-South", 'region' => "Area 51B", 'zip' => "04554", 'country' => "Europe (no, it isn't)")); }
// define vcard $vcard = new VCard(); // define variables $firstname = 'Jeroen'; $lastname = 'Desloovere'; $additional = ''; $prefix = ''; $suffix = ''; // add personal data $vcard->addName($lastname, $firstname, $additional, $prefix, $suffix); // add work data $vcard->addCompany('Siesqo'); $vcard->addJobtitle('Web Developer'); $vcard->addEmail('*****@*****.**'); $vcard->addPhoneNumber(1234121212, 'PREF;WORK'); $vcard->addPhoneNumber(123456789, 'WORK'); $vcard->addAddress(null, null, 'street', 'worktown', null, 'workpostcode', 'Belgium'); $vcard->addURL('http://www.jeroendesloovere.be'); $vcard->addPhoto(__DIR__ . '/assets/landscape.jpeg'); //$vcard->addPhoto('https://raw.githubusercontent.com/jeroendesloovere/vcard/master/tests/image.jpg'); // return vcard as a string //return $vcard->getOutput(); // return vcard as a download return $vcard->download(); // echo message echo 'A personal vCard is saved in this folder: ' . __DIR__; // or // save the card in file in the current folder // return $vcard->save(); // echo message // echo 'A personal vCard is saved in this folder: ' . __DIR__;
public function testAddAddress() { $this->assertEquals($this->vcard, $this->vcard->addAddress()); }
private function _createVcardData(VCardModel $vcardModel) { $vcard = new VCard(); $vcard->addName($vcardModel->lastName, $vcardModel->firstName, $vcardModel->additional, $vcardModel->prefix, $vcardModel->suffix); if ($vcardModel->company) { $vcard->addCompany($vcardModel->company); } if ($vcardModel->jobTitle) { $vcard->addJobtitle($vcardModel->jobTitle); } if ($vcardModel->url and is_array($vcardModel->url)) { foreach ($vcardModel->url as $url) { if ($url instanceof VCard_UrlModel) { if ($url->validate()) { $vcard->addUrl($url->address, $url->type); } } } } if ($vcardModel->address and is_array($vcardModel->address)) { foreach ($vcardModel->address as $address) { if ($address instanceof VCard_AddressModel) { if ($address->validate()) { $vcard->addAddress($address->name, $address->extended, $address->street, $address->city, $address->region, $address->zip, $address->country, $address->type); } } } } if ($vcardModel->phoneNumber and is_array($vcardModel->phoneNumber)) { foreach ($vcardModel->phoneNumber as $phoneNumber) { if ($phoneNumber instanceof VCard_PhoneNumberModel) { if ($phoneNumber->validate()) { $vcard->addPhoneNumber($phoneNumber->number, $phoneNumber->type); } } } } if ($vcardModel->email and is_array($vcardModel->email)) { foreach ($vcardModel->email as $email) { if ($email instanceof VCard_EmailModel) { if ($email->validate()) { $vcard->addEmail($email->address, $email->type); } } } } if ($vcardModel->photo) { $vcard->addPhoto($vcardModel->photo); } if ($vcardModel->note) { $vcard->addNote($vcardModel->note); } return $vcard; }