diff --git a/README-en.md b/README-en.md
index 4b20a73..35f7c57 100644
--- a/README-en.md
+++ b/README-en.md
@@ -22,7 +22,6 @@ $ composer require tim168/ip
use Tim168\Ip\Ip;
- $ip = new Ip('zh-CN'); //Support the following languages
## Supported language formats
| character| describe |
| :------------ | :------------ |
@@ -35,7 +34,7 @@ $ composer require tim168/ip
| zh-CN | chinese |
| ru | russian |
## Get Ip location information
- $res = $ip->get('json','116.234.222.36')
+ $res = Ip::getIp('json','116.234.222.36')
## Example
{
@@ -55,7 +54,7 @@ $ composer require tim168/ip
"query": "116.234.222.36"
}
## Get Xml Format
- $res = $ip->get('xml','116.234.222.36')
+ $res = Ip::getIp('xml','116.234.222.36')
## Example
@@ -75,7 +74,7 @@ $ composer require tim168/ip
116.234.222.36
## GET Csv Format
- $res = $ip->get('csv','116.234.222.36')
+ $res = Ip::getIp('csv','116.234.222.36')
## Example
success,China,CN,SH,Shanghai,Shanghai,,31.0449,121.4012,Asia/Shanghai,China Telecom (Group),Chinanet SH,AS4812 China
Telecom (Group),116.234.222.36
@@ -86,13 +85,13 @@ $ composer require tim168/ip
Telecom (Group)";s:3:"org";s:11:"Chinanet SH";s:2:"as";s:28:"AS4812 China Telecom
(Group)";s:5:"query";s:14:"116.234.222.36";}
## IpV4 to IpV6
- $res = $ip->IpV4toV6('116.234.222.36')
+ $res = Ip::IpV4toV6('116.234.222.36')
## Example
0000:0000:0000:0000:0000:ffff:74ea:de24
## IpV6 to IpV4
- $res = $ip->IpV6toV4('0000:0000:0000:0000:0000:ffff:74ea:de24')
+ $res = Ip::IpV6toV4('0000:0000:0000:0000:0000:ffff:74ea:de24')
## Example
116.234.222.36
diff --git a/README.md b/README.md
index a4cac03..16bfdcd 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,6 @@ $ composer require tim168/ip
use Tim168\Ip\Ip;
- $ip = new Ip('zh-CN'); //支持以下语言
## 支持的语言格式
| 字符集| 描述 |
| :------------ | :------------ |
@@ -36,7 +35,7 @@ $ composer require tim168/ip
| zh-CN | 中文 |
| ru | 俄语 |
## 获取Ip定位信息
- $res = $ip->get('json','116.234.222.36')
+ $res = Ip::getIp('json','116.234.222.36')
## 示例
{
@@ -56,7 +55,7 @@ $ composer require tim168/ip
"query": "116.234.222.36" //ip
}
## 获取XML格式
- $res = $ip->get('xml','116.234.222.36')
+ $res = Ip::getIp('xml','116.234.222.36')
## 示例
@@ -76,24 +75,24 @@ $ composer require tim168/ip
116.234.222.36
## 获取CSV格式
- $res = $ip->get('csv','116.234.222.36')
+ $res = Ip::getIp('csv','116.234.222.36')
## 示例
success,中国,CN,SH,上海,上海,,31.0449,121.4012,Asia/Shanghai,China Telecom (Group),Chinanet SH,AS4812 China Telecom
(Group),116.234.222.36
## 获取序列化格式
- $res = $ip->get('php','116.234.222.36')
+ $res = Ip::getIp('php','116.234.222.36')
## 示例
a:14:{s:6:"status";s:7:"success";s:7:"country";s:6:"中国";s:11:"countryCode";s:2:"CN";s:6:"region";s:2:"SH";s:10:"regionName";s:6:"上海";s:4:"city";s:6:"上海";s:3:"zip";s:0:"";s:3:"lat";d:31.0449;s:3:"lon";d:121.4012;s:8:"timezone";s:13:"Asia/Shanghai";s:3:"isp";s:21:"China
Telecom (Group)";s:3:"org";s:11:"Chinanet SH";s:2:"as";s:28:"AS4812 China Telecom
(Group)";s:5:"query";s:14:"116.234.222.36";}
## IpV4转换成IpV6
- $res = $ip->IpV4toV6('116.234.222.36')
+ $res = Ip::IpV4toV6('116.234.222.36')
## 示例
0000:0000:0000:0000:0000:ffff:74ea:de24
## IpV6转换成IpV4
- $res = $ip->IpV6toV4('0000:0000:0000:0000:0000:ffff:74ea:de24')
+ $res = Ip::IpV6toV4('0000:0000:0000:0000:0000:ffff:74ea:de24')
## 示例
116.234.222.36
diff --git a/src/Ip.php b/src/Ip.php
index cf25d60..0cc7426 100644
--- a/src/Ip.php
+++ b/src/Ip.php
@@ -75,7 +75,7 @@ public static function checkIp($ip)
* @param $ip
* @throws InvalidArgumentException
*/
- public function checkIpV4($ip)
+ public static function checkIpV4($ip)
{
if (!empty($ip)) {
if (!filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
@@ -88,7 +88,7 @@ public function checkIpV4($ip)
* @param $ip
* @throws InvalidArgumentException
*/
- public function checkIpV6($ip)
+ public static function checkIpV6($ip)
{
if (!empty($ip)) {
if (!filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
@@ -102,9 +102,9 @@ public function checkIpV6($ip)
* @return string
* @throws InvalidArgumentException
*/
- public function IpV4toV6($ip)
+ public static function IpV4toV6($ip)
{
- $this->checkIpV4($ip);
+ self::checkIpV4($ip);
$set = '0000:0000:0000:0000:0000:ffff:';
$arr = explode('.', $ip);
$new = [];
@@ -124,9 +124,9 @@ public function IpV4toV6($ip)
* @return string
* @throws InvalidArgumentException
*/
- public function IpV6toV4($ip)
+ public static function IpV6toV4($ip)
{
- $this->checkIpV6($ip);
+ self::checkIpV6($ip);
$str = mb_substr($ip, 30, 38);
$arr = explode(':', $str);
$Ip1 = base_convert(mb_substr($arr[0], 0, 2), 16, 10);