@ 2014-07-02T14:07:42Z <?php
/**
* @xmlNamespace http://www.webservices.nl/soap/
* @xmlType
* @xmlName RiskAddress
*/
class Address
{
/**
* @xmlType string
* @xmlRender value
* @xmlName postcode
* @xmlNamespace http://www.webservices.nl/soap/
*/
protected $_postcode;
/**
* @xmlType string
* @xmlRender value
* @xmlName building
* @xmlNamespace http://www.webservices.nl/soap/
*/
protected $_building;
/**
* @xmlType string
* @xmlRender value
* @xmlName street
* @xmlNamespace http://www.webservices.nl/soap/
*/
protected $_street;
/**
* @xmlType integer
* @xmlRender value
* @xmlName house_number
* @xmlNamespace http://www.webservices.nl/soap/
*/
protected $_house_number;
/**
* @xmlType string
* @xmlRender value
* @xmlName house_number_addition
* @xmlNamespace http://www.webservices.nl/soap/
*/
protected $_house_number_addition;
/**
* @xmlType string
* @xmlRender value
* @xmlName city
* @xmlNamespace http://www.webservices.nl/soap/
*/
protected $_city;
/**
* @xmlType string
* @xmlRender value
* @xmlName municipality
* @xmlNamespace http://www.webservices.nl/soap/
*/
protected $_municipality;
/**
* @xmlType string
* @xmlRender value
* @xmlName state
* @xmlNamespace http://www.webservices.nl/soap/
*/
protected $_state;
/**
* @xmlType string
* @xmlRender value
* @xmlName country
* @xmlNamespace http://www.webservices.nl/soap/
*/
protected $_country;
/**
* @return string
*/
public function getPostcode()
{
return $this->_postcode;
}
/**
* @param string $postcode
*/
public function setPostcode($postcode)
{
$this->_postcode = (string) $postcode;
}
/**
* @return string
*/
public function getBuilding()
{
return $this->_building;
}
/**
* @param string $building
*/
public function setBuilding($building)
{
$this->_building = (string) $building;
}
/**
* @return string
*/
public function getStreet()
{
return $this->_street;
}
/**
* @param string $street
*/
public function setStreet($street)
{
$this->_street = (string) $street;
}
/**
* @return integer
*/
public function getHouseNumber()
{
return $this->_house_number;
}
/**
* @param (integer) $houseNumber
*/
public function setHouseNumber($houseNumber)
{
$this->_house_number = (integer) $houseNumber;
}
/**
* @return string
*/
public function getHouseNumberAddition()
{
return $this->_house_number_addition;
}
/**
* @param string $houseNumberAddition
*/
public function setHouseNumberAddition($houseNumberAddition)
{
$this->_house_number_addition = (string) $houseNumberAddition;
}
/**
* @return string
*/
public function getCity()
{
return $this->_city;
}
/**
* @param string $city
*/
public function setCity($city)
{
$this->_city = (string) $city;
}
/**
* @return string
*/
public function getMunicipality()
{
return $this->_municipality;
}
/**
* @param string $municipality
*/
public function setMunicipality($municipality)
{
$this->_municipality = $municipality;
}
/**
* @return string
*/
public function getState()
{
return $this->_state;
}
/**
* @param string $state
*/
public function setState($state)
{
$this->_state = (string) $state;
}
/**
* @return string
*/
public function getCountry()
{
return $this->_country;
}
/**
* @param string $country
*/
public function setCountry($country)
{
$this->_country = (string) $country;
}
}
class AddressHelper
{
public static function parse(Address $address, $parts)
{
$parts = func_get_args();
$address = array_shift($parts);
$format = '~^(.*?\n)??'
. '(?<street>[^0-9].*|.*?[^0-9])[\b\s]*?'
. '(?<number>[0-9]{1,5}?)[\b\s\-]*?'
. '(?<addition>[^\s]*?)[\b\s,]*?'
. '(?<postcode>[0-9]{4}\s?[A-Z]{2})[\b\s,]*?'
. '(?<city>[\w][\w\s]*?)'
. '(\n.*)??$~msiU';
if (preg_match($format, implode(PHP_EOL, $parts), $args))
{
$street = $number = $postcode = $city = $addition = null;
extract($args, EXTR_OVERWRITE);
$address->setStreet($street);
$address->setHouseNumber($number);
$address->setHouseNumberAddition($addition);
$address->setPostcode($postcode);
$address->setCity(strtoupper(trim($city)));
}
return $address;
}
}
echo AddressHelper::parse(new Address(), null, null, null, null, null);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Fatal error: Uncaught Error: Object of class Address could not be converted to string in /in/s6bPc:262
Stack trace:
#0 {main}
thrown in /in/s6bPc on line 262
Process exited with code 255 . Output for 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 Recoverable fatal error: Object of class Address could not be converted to string in /in/s6bPc on line 262
Process exited with code 255 . Output for 5.2.2 - 5.2.17 , 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.24 - 5.5.35 , 5.6.8 - 5.6.28 , 7.0.0 - 7.0.20 Catchable fatal error: Object of class Address could not be converted to string in /in/s6bPc on line 262
Process exited with code 255 . Output for 5.2.0 - 5.2.1 Warning: preg_match(): Compilation failed: unrecognized character after (?< at offset 13 in /in/s6bPc on line 245
Catchable fatal error: Object of class Address could not be converted to string in /in/s6bPc on line 262
Process exited with code 255 . Output for 5.0.2 - 5.0.5 , 5.1.0 - 5.1.6 Warning: preg_match(): Compilation failed: unrecognized character after (?< at offset 13 in /in/s6bPc on line 245
Object id #1 Output for 5.0.0 - 5.0.1 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/s6bPc on line 245
Warning: preg_match(): Compilation failed: unrecognized character after (?< at offset 13 in /in/s6bPc on line 245
Object id #1 Output for 4.4.2 - 4.4.9 Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/s6bPc on line 17
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/s6bPc on line 17
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/s6bPc on line 17
Process exited with code 255 . preferences:dark mode live preview
255.67 ms | 401 KiB | 356 Q