protected function emailFromArray(array $arr)
    {
        if (isset($arr['address'])) {
            $arr['email'] = $arr['address'];
            unset($arr['address']);
        }

        if (!isset($arr['email'])) {
            throw new InvalidArgumentException(
                'The array must contain at least the "address" key.'
            );
        }

        $email = strval(filter_var($arr['email'], FILTER_SANITIZE_EMAIL));

        if (!isset($arr['name']) || $arr['name'] === '') {
            return $email;
        }

        $name = str_replace('"', '', filter_var($arr['name'], FILTER_SANITIZE_STRING));
        return sprintf('"%s" <%s>', $name, $email);
    }
protected function emailFromArray(array $arr)
    {
        if (isset($arr['address'])) {
            $arr['email'] = $arr['address'];
            unset($arr['address']);
        }

        if (!isset($arr['email'])) {
            throw new InvalidArgumentException(
                'The array must contain at least the "address" key.'
            );
        }

        $email = strval(filter_var($arr['email'], FILTER_SANITIZE_EMAIL));

        if (!isset($arr['name']) || $arr['name'] === '') {
            return $email;
        }

        $name = str_replace('"', '', filter_var($arr['name'], FILTER_SANITIZE_STRING));
        return sprintf('"%s" <%s>', $name, $email);
    }
protected function emailFromArray ( array $ arr ) { if ( isset ( $ arr [ 'address' ] ) ) { $ arr [ 'email' ] = $ arr [ 'address' ] ; unset ( $ arr [ 'address' ] ) ; } if ( ! isset ( $ arr [ 'email' ] ) ) { throw new InvalidArgumentException ( 'The array must contain at least the "address" key.' ) ; } $ email = strval ( filter_var ( $ arr [ 'email' ] , FILTER_SANITIZE_EMAIL ) ) ; if ( ! isset ( $ arr [ 'name' ] ) || $ arr [ 'name' ] === '' ) { return $ email ; } $ name = str_replace ( '"' , '' , filter_var ( $ arr [ 'name' ] , FILTER_SANITIZE_STRING ) ) ; return sprintf ( '"%s" <%s>' , $ name , $ email ) ; }
Convert an email address array to a RFC-822 string notation.

@param  array $arr An email array (containing an "email" key and optionally a "name" key).
@throws InvalidArgumentException If the email array is invalid.
@return string
Convert an email address array to a RFC - 822 string notation .