public function setPostalCode($postalCode = null) { // validation for constraint: length if (is_scalar($postalCode) && strlen($postalCode) !== 4 || is_array($postalCode) && count($postalCode) !== 4) { throw new \InvalidArgumentException('Invalid length, please provide an array with 4 element(s) or a scalar of 4 character(s)', __LINE__); } // validation for constraint: string if (!is_null($postalCode) && !is_string($postalCode)) { throw new \InvalidArgumentException(sprintf('Invalid value, please provide a string, "%s" given', gettype($postalCode)), __LINE__); } $this->PostalCode = $postalCode; return $this; }