Skip to content

Commit 320ea7c

Browse files
committed
update
1 parent 2a76c0a commit 320ea7c

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

README-en.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ $ composer require tim168/ip
2222

2323
use Tim168\Ip\Ip;
2424

25-
$ip = new Ip('zh-CN'); //Support the following languages
2625
## Supported language formats
2726
| character| describe |
2827
| :------------ | :------------ |
@@ -35,7 +34,7 @@ $ composer require tim168/ip
3534
| zh-CN | chinese |
3635
| ru | russian |
3736
## Get Ip location information
38-
$res = $ip->get('json','116.234.222.36')
37+
$res = Ip::getIp('json','116.234.222.36')
3938

4039
## Example
4140
{
@@ -55,7 +54,7 @@ $ composer require tim168/ip
5554
"query": "116.234.222.36"
5655
}
5756
## Get Xml Format
58-
$res = $ip->get('xml','116.234.222.36')
57+
$res = Ip::getIp('xml','116.234.222.36')
5958
## Example
6059
<?xml version="1.0" encoding="UTF-8"?>
6160
<query>
@@ -75,7 +74,7 @@ $ composer require tim168/ip
7574
<query>116.234.222.36</query>
7675
</query>
7776
## GET Csv Format
78-
$res = $ip->get('csv','116.234.222.36')
77+
$res = Ip::getIp('csv','116.234.222.36')
7978
## Example
8079
success,China,CN,SH,Shanghai,Shanghai,,31.0449,121.4012,Asia/Shanghai,China Telecom (Group),Chinanet SH,AS4812 China
8180
Telecom (Group),116.234.222.36
@@ -86,13 +85,13 @@ $ composer require tim168/ip
8685
Telecom (Group)";s:3:"org";s:11:"Chinanet SH";s:2:"as";s:28:"AS4812 China Telecom
8786
(Group)";s:5:"query";s:14:"116.234.222.36";}
8887
## IpV4 to IpV6
89-
$res = $ip->IpV4toV6('116.234.222.36')
88+
$res = Ip::IpV4toV6('116.234.222.36')
9089

9190
## Example
9291
0000:0000:0000:0000:0000:ffff:74ea:de24
9392

9493
## IpV6 to IpV4
95-
$res = $ip->IpV6toV4('0000:0000:0000:0000:0000:ffff:74ea:de24')
94+
$res = Ip::IpV6toV4('0000:0000:0000:0000:0000:ffff:74ea:de24')
9695

9796
## Example
9897
116.234.222.36

README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ $ composer require tim168/ip
2323

2424
use Tim168\Ip\Ip;
2525

26-
$ip = new Ip('zh-CN'); //支持以下语言
2726
## 支持的语言格式
2827
| 字符集| 描述 |
2928
| :------------ | :------------ |
@@ -36,7 +35,7 @@ $ composer require tim168/ip
3635
| zh-CN | 中文 |
3736
| ru | 俄语 |
3837
## 获取Ip定位信息
39-
$res = $ip->get('json','116.234.222.36')
38+
$res = Ip::getIp('json','116.234.222.36')
4039

4140
## 示例
4241
{
@@ -56,7 +55,7 @@ $ composer require tim168/ip
5655
"query": "116.234.222.36" //ip
5756
}
5857
## 获取XML格式
59-
$res = $ip->get('xml','116.234.222.36')
58+
$res = Ip::getIp('xml','116.234.222.36')
6059
## 示例
6160
<?xml version="1.0" encoding="UTF-8"?>
6261
<query>
@@ -76,24 +75,24 @@ $ composer require tim168/ip
7675
<query>116.234.222.36</query>
7776
</query>
7877
## 获取CSV格式
79-
$res = $ip->get('csv','116.234.222.36')
78+
$res = Ip::getIp('csv','116.234.222.36')
8079
## 示例
8180
success,中国,CN,SH,上海,上海,,31.0449,121.4012,Asia/Shanghai,China Telecom (Group),Chinanet SH,AS4812 China Telecom
8281
(Group),116.234.222.36
8382
## 获取序列化格式
84-
$res = $ip->get('php','116.234.222.36')
83+
$res = Ip::getIp('php','116.234.222.36')
8584
## 示例
8685
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
8786
Telecom (Group)";s:3:"org";s:11:"Chinanet SH";s:2:"as";s:28:"AS4812 China Telecom
8887
(Group)";s:5:"query";s:14:"116.234.222.36";}
8988
## IpV4转换成IpV6
90-
$res = $ip->IpV4toV6('116.234.222.36')
89+
$res = Ip::IpV4toV6('116.234.222.36')
9190

9291
## 示例
9392
0000:0000:0000:0000:0000:ffff:74ea:de24
9493

9594
## IpV6转换成IpV4
96-
$res = $ip->IpV6toV4('0000:0000:0000:0000:0000:ffff:74ea:de24')
95+
$res = Ip::IpV6toV4('0000:0000:0000:0000:0000:ffff:74ea:de24')
9796

9897
## 示例
9998
116.234.222.36

src/Ip.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static function checkIp($ip)
7575
* @param $ip
7676
* @throws InvalidArgumentException
7777
*/
78-
public function checkIpV4($ip)
78+
public static function checkIpV4($ip)
7979
{
8080
if (!empty($ip)) {
8181
if (!filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
@@ -88,7 +88,7 @@ public function checkIpV4($ip)
8888
* @param $ip
8989
* @throws InvalidArgumentException
9090
*/
91-
public function checkIpV6($ip)
91+
public static function checkIpV6($ip)
9292
{
9393
if (!empty($ip)) {
9494
if (!filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
@@ -102,9 +102,9 @@ public function checkIpV6($ip)
102102
* @return string
103103
* @throws InvalidArgumentException
104104
*/
105-
public function IpV4toV6($ip)
105+
public static function IpV4toV6($ip)
106106
{
107-
$this->checkIpV4($ip);
107+
self::checkIpV4($ip);
108108
$set = '0000:0000:0000:0000:0000:ffff:';
109109
$arr = explode('.', $ip);
110110
$new = [];
@@ -124,9 +124,9 @@ public function IpV4toV6($ip)
124124
* @return string
125125
* @throws InvalidArgumentException
126126
*/
127-
public function IpV6toV4($ip)
127+
public static function IpV6toV4($ip)
128128
{
129-
$this->checkIpV6($ip);
129+
self::checkIpV6($ip);
130130
$str = mb_substr($ip, 30, 38);
131131
$arr = explode(':', $str);
132132
$Ip1 = base_convert(mb_substr($arr[0], 0, 2), 16, 10);

0 commit comments

Comments
 (0)