Api\StructType\ApiShopper::setEmail PHP Method

setEmail() public method

Set email value
public setEmail ( string $email = null ) : ApiShopper
$email string
return ApiShopper
    public function setEmail($email = null)
    {
        // validation for constraint: pattern
        if (is_scalar($email) && !preg_match('/[_a-zA-Z0-9\\-\\+\\.]+@[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)*(\\.[a-zA-Z]+)/', $email)) {
            throw new \InvalidArgumentException(sprintf('Invalid value, please provide a scalar value that matches "[_a-zA-Z0-9\\-\\+\\.]+@[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)*(\\.[a-zA-Z]+)", "%s" given', var_export($email, true)), __LINE__);
        }
        // validation for constraint: maxLength
        if (is_scalar($email) && strlen($email) > 100 || is_array($email) && count($email) > 100) {
            throw new \InvalidArgumentException(sprintf('Invalid length, please provide an array with 100 element(s) or a scalar of 100 character(s) at most, "%d" length given', is_scalar($email) ? strlen($email) : count($email)), __LINE__);
        }
        // validation for constraint: minLength
        if (is_scalar($email) && strlen($email) < 1 || is_array($email) && count($email) < 1) {
            throw new \InvalidArgumentException('Invalid length, please provide an array with 1 element(s) or a scalar of 1 character(s) at least', __LINE__);
        }
        // validation for constraint: string
        if (!is_null($email) && !is_string($email)) {
            throw new \InvalidArgumentException(sprintf('Invalid value, please provide a string, "%s" given', gettype($email)), __LINE__);
        }
        $this->email = $email;
        return $this;
    }