Skip to content

Commit a320c2c

Browse files
authored
Merge pull request #172 from maxmind/greg/mcc-mnc
Add MCC/MNC support
2 parents 5397d11 + fdae39f commit a320c2c

File tree

8 files changed

+70
-12
lines changed

8 files changed

+70
-12
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
CHANGELOG
22
=========
33

4+
2.12.0
5+
-------------------
6+
7+
* Support for mobile country code (MCC) and mobile network codes (MNC) was
8+
 added for the GeoIP2 ISP and Enterprise databases as well as the GeoIP2
9+
 City and Insights web services. `$mobileCountryCode` and
10+
`$mobileNetworkCode` properties were added to `GeoIp2\Model\Isp`
11+
 for the GeoIP2 ISP database and `GeoIp2\Record\Traits` for the Enterprise
12+
database and the GeoIP2 City and Insights web services. We expect this data
13+
to be available by late January, 2022.
14+
* `geoip2.phar` is now generated with Box 3.x.
15+
416
2.11.0 (2020-10-01)
517
-------------------
618

box.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
"main": "phar-stub.php",
44
"output": "geoip2.phar",
55
"compactors": [
6-
"Herrera\\Box\\Compactor\\Composer",
7-
"Herrera\\Box\\Compactor\\Json",
8-
"Herrera\\Box\\Compactor\\Php"
6+
"KevinGH\\Box\\Compactor\\Php",
7+
"KevinGH\\Box\\Compactor\\Json"
98
],
109
"files": [
1110
"LICENSE"
@@ -38,6 +37,5 @@
3837
}
3938
],
4039
"git-version": "git-version",
41-
"shebang": false,
42-
"stub": true
40+
"shebang": false
4341
}

dev-bin/release.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ php composer.phar update --no-dev
4545
perl -pi -e "s/(?<=const VERSION = ').+?(?=';)/$tag/g" src/WebService/Client.php
4646

4747
if [ ! -f box.phar ]; then
48-
wget -O box.phar "https://github.com/box-project/box2/releases/download/2.7.5/box-2.7.5.phar"
48+
wget -O box.phar "https://github.com/box-project/box/releases/download/3.13.0/box.phar"
4949
fi
5050

51-
php box.phar build
51+
php box.phar compile
5252

5353
phar_test=$(./dev-bin/phar-test.php)
5454
if [[ -n $phar_test ]]; then
@@ -88,7 +88,7 @@ if [ -n "$(git status --porcelain)" ]; then
8888
fi
8989

9090
# Using Composer is possible, but they don't recommend it.
91-
wget -O phpDocumentor.phar https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0/phpDocumentor.phar
91+
wget -O phpDocumentor.phar https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.1.2/phpDocumentor.phar
9292

9393
# Use cache dir in /tmp as otherwise cache files get into the output directory.
9494
cachedir="/tmp/phpdoc-$$-$RANDOM"

maxmind-db

Submodule maxmind-db updated 46 files

src/Model/Isp.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
* address.
1717
* @property-read string|null $isp The name of the ISP associated with the IP
1818
* address.
19+
* @property-read string|null $mobileCountryCode The [mobile country code
20+
* (MCC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
21+
* the IP address and ISP.
22+
* @property-read string|null $mobileNetworkCode The [mobile network code
23+
* (MNC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
24+
* the IP address and ISP.
1925
* @property-read string|null $organization The name of the organization associated
2026
* with the IP address.
2127
* @property-read string $ipAddress The IP address that the data in the model is
@@ -38,6 +44,14 @@ class Isp extends AbstractModel
3844
* @var string|null
3945
*/
4046
protected $isp;
47+
/**
48+
* @var string|null
49+
*/
50+
protected $mobileCountryCode;
51+
/**
52+
* @var string|null
53+
*/
54+
protected $mobileNetworkCode;
4155
/**
4256
* @var string|null
4357
*/
@@ -61,6 +75,8 @@ public function __construct(array $raw)
6175
$this->autonomousSystemOrganization =
6276
$this->get('autonomous_system_organization');
6377
$this->isp = $this->get('isp');
78+
$this->mobileCountryCode = $this->get('mobile_country_code');
79+
$this->mobileNetworkCode = $this->get('mobile_network_code');
6480
$this->organization = $this->get('organization');
6581

6682
$ipAddress = $this->get('ip_address');

src/Record/Traits.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@
7676
* @property-read string|null $organization The name of the organization associated
7777
* with the IP address. This attribute is only available from the City and
7878
* Insights web services and the GeoIP2 Enterprise database.
79+
* @property-read string|null $mobileCountryCode The [mobile country code
80+
* (MCC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
81+
* the IP address and ISP. This property is available from the City and
82+
* Insights web services and the GeoIP2 Enterprise database.
83+
* @property-read string|null $mobileNetworkCode The [mobile network code
84+
* (MNC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
85+
* the IP address and ISP. This property is available from the City and
86+
* Insights web services and the GeoIP2 Enterprise database.
7987
* @property-read float|null $staticIpScore An indicator of how static or
8088
* dynamic an IP address is. This property is only available from GeoIP2
8189
* Precision Insights.
@@ -130,6 +138,8 @@ class Traits extends AbstractRecord
130138
'isResidentialProxy',
131139
'isSatelliteProvider',
132140
'isTorExitNode',
141+
'mobileCountryCode',
142+
'mobileNetworkCode',
133143
'network',
134144
'organization',
135145
'staticIpScore',

tests/GeoIp2/Test/Database/ReaderTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ public function testHasIpAddressAndNetwork(string $type, string $method): void
6262
public function testIsInEuropeanUnion(string $type, string $method): void
6363
{
6464
$reader = new Reader("maxmind-db/test-data/GeoIP2-$type-Test.mmdb");
65-
$record = $reader->{$method}('81.2.69.160');
65+
$record = $reader->{$method}('2a02:cfc0::');
6666
$this->assertTrue(
6767
$record->country->isInEuropeanUnion,
6868
'country is_in_european_union is true'
6969
);
70-
$this->assertFalse(
70+
$this->assertTrue(
7171
$record->registeredCountry->isInEuropeanUnion,
72-
'registered_country is_in_european_union is false'
72+
'registered_country is_in_european_union is true'
7373
);
7474
$reader->close();
7575
}
@@ -210,6 +210,10 @@ public function testEnterprise(): void
210210
$this->assertSame($ipAddress, $record->traits->ipAddress);
211211
$this->assertSame('74.209.16.0/20', $record->traits->network);
212212

213+
$record = $reader->enterprise('149.101.100.0');
214+
$this->assertSame('310', $record->traits->mobileCountryCode);
215+
$this->assertSame('004', $record->traits->mobileNetworkCode);
216+
213217
$reader->close();
214218
}
215219

@@ -231,6 +235,10 @@ public function testIsp(): void
231235
$this->assertSame($ipAddress, $record->ipAddress);
232236
$this->assertSame('1.128.0.0/11', $record->network);
233237

238+
$record = $reader->isp('149.101.100.0');
239+
$this->assertSame('310', $record->mobileCountryCode);
240+
$this->assertSame('004', $record->mobileNetworkCode);
241+
234242
$reader->close();
235243
}
236244

tests/GeoIp2/Test/Model/InsightsTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public function testFull(): void
7878
'is_satellite_provider' => true,
7979
'is_tor_exit_node' => true,
8080
'isp' => 'Comcast',
81+
'mobile_country_code' => '310',
82+
'mobile_network_code' => '004',
8183
'organization' => 'Blorg',
8284
'static_ip_score' => 1.3,
8385
'user_count' => 2,
@@ -193,6 +195,18 @@ public function testFull(): void
193195
'$model->traits->isAnonymousProxy is false'
194196
);
195197

198+
$this->assertSame(
199+
'310',
200+
$model->traits->mobileCountryCode,
201+
'mobileCountryCode is correct'
202+
);
203+
204+
$this->assertSame(
205+
'004',
206+
$model->traits->mobileNetworkCode,
207+
'mobileNetworkCode is correct'
208+
);
209+
196210
$this->assertSame(
197211
1.3,
198212
$model->traits->staticIpScore,

0 commit comments

Comments
 (0)