JeroenDesloovere\VCard\VCard::addAddress PHP Method

addAddress() public method

Add address
public addAddress ( $name = '', $extended = '', $street = '', $city = '', $region = '', $zip = '', $country = '', $type = 'WORK;POSTAL' )
    public function addAddress($name = '', $extended = '', $street = '', $city = '', $region = '', $zip = '', $country = '', $type = 'WORK;POSTAL')
    {
        // init value
        $value = $name . ';' . $extended . ';' . $street . ';' . $city . ';' . $region . ';' . $zip . ';' . $country;
        // set property
        $this->setProperty('address', 'ADR' . ($type != '' ? ';' . $type : '') . $this->getCharsetString(), $value);
        return $this;
    }

Usage Example

 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)"));
 }
All Usage Examples Of JeroenDesloovere\VCard\VCard::addAddress