Requests_IRI
概述
Requests_IRI 是一个用于解析、序列化和规范化 IRI(国际化资源标识符)的类,属于 WordPress 开发中的 Requests 库组件。它提供了一系列方法来操作 IRI 的各个部分,如方案、权限、路径、查询和片段。
关键要点
- Requests_IRI 类用于处理 IRI,支持解析、序列化和规范化操作。
- 提供构造函数和魔术方法(如 __get、__set、__toString)以方便访问和操作 IRI 属性。
- 包含方法用于创建绝对 IRI、获取或设置 IRI 组件(如权限、主机、路径、查询、片段)、验证 IRI 有效性以及转换 IRI 为 URI。
- 支持移除路径中的点段、替换无效字符为百分比编码等规范化功能。
- 所有方法均返回布尔值指示操作成功或失败,便于错误处理。
IRI parser/serialiser/normaliser
Description
Copyright (c) 2007-2010, Geoffrey Sneddon and Steve Minutillo.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
Neither the name of the SimplePie Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Methods
| Name | Description |
|---|---|
| Requests_IRI::__construct | Create a new IRI object, from a specified string |
| Requests_IRI::__get | Overload __get() to provide access via properties |
| Requests_IRI::__isset | Overload __isset() to provide access via properties |
| Requests_IRI::__set | Overload __set() to provide access via properties |
| Requests_IRI::__toString | Return the entire IRI when you try and read the object as a string |
| Requests_IRI::__unset | Overload __unset() to provide access via properties |
| Requests_IRI::absolutize | Create a new IRI object by resolving a relative IRI |
| Requests_IRI::get_authority | Get the complete authority |
| Requests_IRI::get_iauthority | Get the complete iauthority |
| Requests_IRI::get_iri | Get the complete IRI |
| Requests_IRI::get_uri | Get the complete URI |
| Requests_IRI::is_valid | Check if the object represents a valid IRI. This needs to be done on each call as some things change depending on another part of the IRI. |
| Requests_IRI::parse_iri | Parse an IRI into scheme/authority/path/query/fragment segments |
| Requests_IRI::remove_dot_segments | Remove dot segments from a path |
| Requests_IRI::remove_iunreserved_percent_encoded | Callback function for preg_replace_callback. |
| Requests_IRI::replace_invalid_with_pct_encoding | Replace invalid character with percent encoding |
| Requests_IRI::scheme_normalization | – |
| Requests_IRI::set_authority | Set the authority. Returns true on success, false on failure (if there are any invalid characters). |
| Requests_IRI::set_fragment | Set the ifragment. |
| Requests_IRI::set_host | Set the ihost. Returns true on success, false on failure (if there are any invalid characters). |
| Requests_IRI::set_iri | Set the entire IRI. Returns true on success, false on failure (if there are any invalid characters). |
| Requests_IRI::set_path | Set the ipath. |
| Requests_IRI::set_port | Set the port. Returns true on success, false on failure (if there are any invalid characters). |
| Requests_IRI::set_query | Set the iquery. |
| Requests_IRI::set_scheme | Set the scheme. Returns true on success, false on failure (if there are any invalid characters). |
| Requests_IRI::set_userinfo | Set the iuserinfo. |
| Requests_IRI::to_uri | Convert an IRI to a URI (or parts thereof) |