Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 17a8fa6

Browse files
author
Martin Brecht-Precht
committedJan 18, 2021
Updated root namespace and vendor prefix
1 parent 299fb9e commit 17a8fa6

7 files changed

+67
-55
lines changed
 

‎LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Martin Brecht-Precht, Markenwerk GmbH
3+
Copyright (c) 2016 Martin Brecht-Precht, Chroma Experience GmbH
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

‎README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# PHP ISO3166 Country Information
22

3-
[![Build Status](https://travis-ci.org/markenwerk/php-iso3166-country-information.svg?branch=master)](https://travis-ci.org/markenwerk/php-iso3166-country-information)
4-
[![Test Coverage](https://codeclimate.com/github/markenwerk/php-iso3166-country-information/badges/coverage.svg)](https://codeclimate.com/github/markenwerk/php-iso3166-country-information/coverage)
3+
[![Build Status](https://travis-ci.org/chroma-x/php-iso3166-country-information.svg?branch=master)](https://travis-ci.org/chroma-x/php-iso3166-country-information)
4+
[![Test Coverage](https://codeclimate.com/github/chroma-x/php-iso3166-country-information/badges/coverage.svg)](https://codeclimate.com/github/chroma-x/php-iso3166-country-information/coverage)
55
[![SensioLabs Insight](https://img.shields.io/sensiolabs/i/f31c9db5-f884-4aa0-8161-45cfdd81071a.svg)](https://insight.sensiolabs.com/projects/f31c9db5-f884-4aa0-8161-45cfdd81071a)
6-
[![Code Climate](https://codeclimate.com/github/markenwerk/php-iso3166-country-information/badges/gpa.svg)](https://codeclimate.com/github/markenwerk/php-iso3166-country-information)
7-
[![Latest Stable Version](https://poser.pugx.org/markenwerk/iso3166-country-information/v/stable)](https://packagist.org/packages/markenwerk/iso3166-country-information)
8-
[![Total Downloads](https://poser.pugx.org/markenwerk/iso3166-country-information/downloads)](https://packagist.org/packages/markenwerk/iso3166-country-information)
9-
[![License](https://poser.pugx.org/markenwerk/iso3166-country-information/license)](https://packagist.org/packages/markenwerk/iso3166-country-information)
6+
[![Code Climate](https://codeclimate.com/github/chroma-x/php-iso3166-country-information/badges/gpa.svg)](https://codeclimate.com/github/chroma-x/php-iso3166-country-information)
7+
[![Latest Stable Version](https://poser.pugx.org/chroma-x/iso3166-country-information/v/stable)](https://packagist.org/packages/chroma-x/iso3166-country-information)
8+
[![Total Downloads](https://poser.pugx.org/chroma-x/iso3166-country-information/downloads)](https://packagist.org/packages/chroma-x/iso3166-country-information)
9+
[![License](https://poser.pugx.org/chroma-x/iso3166-country-information/license)](https://packagist.org/packages/chroma-x/iso3166-country-information)
1010

1111
ISO3166 util class for validating and listing country codes and getting detailed information for identified countries.
1212

@@ -15,7 +15,7 @@ ISO3166 util class for validating and listing country codes and getting detailed
1515
````{json}
1616
{
1717
"require": {
18-
"markenwerk/iso3166-country-information": "~3.0"
18+
"chroma-x/iso3166-country-information": "~3.0"
1919
}
2020
}
2121
````
@@ -27,8 +27,8 @@ ISO3166 util class for validating and listing country codes and getting detailed
2727
````{php}
2828
require_once('path/to/vendor/autoload.php');
2929
30-
use Markenwerk\Iso3166Country\Iso3166CountryInformation;
31-
use Markenwerk\Iso3166Country\Iso3166Country;
30+
use ChromaX\Iso3166Country\Iso3166CountryInformation;
31+
use ChromaX\Iso3166Country\Iso3166Country;
3232
````
3333

3434
---
@@ -238,8 +238,8 @@ $countryExists = Iso3166CountryInformation::validateUnitedNationsId('de');
238238
#### Creation of an object by country code
239239

240240
````{php}
241-
use Markenwerk\Iso3166Country\Iso3166CountryInformation;
242-
use Markenwerk\Iso3166Country\Iso3166Country;
241+
use ChromaX\Iso3166Country\Iso3166CountryInformation;
242+
use ChromaX\Iso3166Country\Iso3166Country;
243243
244244
$country = new Iso3166Country();
245245
$country->loadByIso3166Alpha2CountryCode('DE');
@@ -279,7 +279,7 @@ $name = $country->getName();
279279
## Contribution
280280

281281
Contributing to our projects is always very appreciated.
282-
**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](https://github.com/markenwerk/php-iso3166-country-information/blob/master/CONTRIBUTING.md) document.**
282+
**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](https://github.com/chroma-x/php-iso3166-country-information/blob/master/CONTRIBUTING.md) document.**
283283

284284
## License
285285

‎composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
2-
"name": "markenwerk/iso3166-country-information",
2+
"name": "chroma-x/iso3166-country-information",
33
"type": "library",
44
"description": "ISO3166 util class for validating and listing country codes and getting detailed information for identified countries.",
55
"keywords": [
66
"ISO3166",
77
"Country code"
88
],
9-
"homepage": "http://markenwerk.net/",
9+
"homepage": "http://chroma-x.de/",
1010
"license": "MIT",
1111
"authors": [
1212
{
1313
"name": "Martin Brecht-Precht",
14-
"email": "mb@markenwerk.net",
15-
"homepage": "http://markenwerk.net"
14+
"email": "mb@chroma-x.de",
15+
"homepage": "http://chroma-x.de"
1616
}
1717
],
1818
"autoload": {
1919
"psr-4": {
20-
"Markenwerk\\Iso3166Country\\": "src/"
20+
"ChromaX\\Iso3166Country\\": "src/"
2121
}
2222
},
2323
"require": {
+5-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

3-
namespace Markenwerk\Iso3166Country\Exception;
3+
namespace ChromaX\Iso3166Country\Exception;
4+
5+
use Exception;
46

57
/**
68
* Class Iso3166CountryException
79
*
8-
* @package Markenwerk\Iso3166Country\Exception
10+
* @package ChromaX\Iso3166Country\Exception
911
*/
10-
class Iso3166CountryException extends \Exception
12+
class Iso3166CountryException extends Exception
1113
{
1214

1315
}

‎src/Iso3166Country.php

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace Markenwerk\Iso3166Country;
3+
namespace ChromaX\Iso3166Country;
44

5-
use Markenwerk\Iso3166Country\Exception\Iso3166CountryException;
5+
use ChromaX\Iso3166Country\Exception\Iso3166CountryException;
66

77
/**
88
* Class Iso3166Country
99
*
10-
* @package Markenwerk\Iso3166Country
10+
* @package ChromaX\Iso3166Country
1111
*/
1212
class Iso3166Country
1313
{
@@ -170,7 +170,7 @@ private function validateInfoByIso3166Alpha2CountryCode(array $iso3166CountryInf
170170
{
171171
if (
172172
!isset($iso3166CountryInfo[Iso3166CountryInformation::ISO3166_ALPHA2])
173-
|| mb_strlen($iso3166CountryInfo[Iso3166CountryInformation::ISO3166_ALPHA2]) != 2
173+
|| mb_strlen($iso3166CountryInfo[Iso3166CountryInformation::ISO3166_ALPHA2]) !== 2
174174
) {
175175
return false;
176176
}
@@ -185,7 +185,7 @@ private function validateInfoByIso3166Alpha3CountryCode(array $iso3166CountryInf
185185
{
186186
if (
187187
!isset($iso3166CountryInfo[Iso3166CountryInformation::ISO3166_ALPHA3])
188-
|| mb_strlen($iso3166CountryInfo[Iso3166CountryInformation::ISO3166_ALPHA3]) != 3
188+
|| mb_strlen($iso3166CountryInfo[Iso3166CountryInformation::ISO3166_ALPHA3]) !== 3
189189
) {
190190
return false;
191191
}
@@ -215,7 +215,7 @@ private function validateInfoByIso3166v2CountryCode(array $iso3166CountryInfo)
215215
{
216216
if (
217217
!isset($iso3166CountryInfo[Iso3166CountryInformation::ISO3166_2])
218-
|| mb_strlen($iso3166CountryInfo[Iso3166CountryInformation::ISO3166_2]) != 2
218+
|| mb_strlen($iso3166CountryInfo[Iso3166CountryInformation::ISO3166_2]) !== 2
219219
) {
220220
return false;
221221
}
@@ -230,7 +230,7 @@ private function validateInfoByUnitedNationsId(array $iso3166CountryInfo)
230230
{
231231
if (
232232
!isset($iso3166CountryInfo[Iso3166CountryInformation::UNITED_NATIONS_ID])
233-
|| mb_strlen($iso3166CountryInfo[Iso3166CountryInformation::UNITED_NATIONS_ID]) == 0
233+
|| $iso3166CountryInfo[Iso3166CountryInformation::UNITED_NATIONS_ID] === ''
234234
) {
235235
return false;
236236
}
@@ -243,10 +243,11 @@ private function validateInfoByUnitedNationsId(array $iso3166CountryInfo)
243243
*/
244244
private function validateInfoByToplevelDomain(array $iso3166CountryInfo)
245245
{
246+
$tldLength = mb_strlen($iso3166CountryInfo[Iso3166CountryInformation::TOP_LEVEL_DOMAIN]);
246247
if (
247248
!isset($iso3166CountryInfo[Iso3166CountryInformation::TOP_LEVEL_DOMAIN])
248-
|| mb_strlen($iso3166CountryInfo[Iso3166CountryInformation::TOP_LEVEL_DOMAIN]) < 2
249-
|| mb_strlen($iso3166CountryInfo[Iso3166CountryInformation::TOP_LEVEL_DOMAIN]) > 4
249+
|| $tldLength < 2
250+
|| $tldLength > 4
250251
) {
251252
return false;
252253
}
@@ -261,7 +262,7 @@ private function validateInfoByName(array $iso3166CountryInfo)
261262
{
262263
if (
263264
!isset($iso3166CountryInfo[Iso3166CountryInformation::NAME])
264-
|| mb_strlen($iso3166CountryInfo[Iso3166CountryInformation::NAME]) == 0
265+
|| $iso3166CountryInfo[Iso3166CountryInformation::NAME] === ''
265266
) {
266267
return false;
267268
}

‎src/Iso3166CountryInformation.php

+23-14
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<?php
22

3-
namespace Markenwerk\Iso3166Country;
3+
namespace ChromaX\Iso3166Country;
4+
5+
use ChromaX\Iso3166Country\Exception\Iso3166CountryException;
6+
use Exception;
47

58
/**
69
* Class Iso3166CountryInformation
710
*
8-
* @package Markenwerk\Iso3166Country
11+
* @package ChromaX\Iso3166Country
912
*/
1013
class Iso3166CountryInformation
1114
{
@@ -44,7 +47,7 @@ public static function getCountries()
4447
$countryData = $country;
4548
$country = new Iso3166Country();
4649
$country->loadByIso3166CountryInformation($countryData);
47-
} catch (\Exception $exception) {
50+
} catch (Exception $exception) {
4851
continue;
4952
}
5053
}
@@ -54,6 +57,7 @@ public static function getCountries()
5457
/**
5558
* @param string $countryCode
5659
* @return Iso3166Country|null
60+
* @throws Iso3166CountryException
5761
*/
5862
public static function getByIso3166Alpha2($countryCode)
5963
{
@@ -69,6 +73,7 @@ public static function getByIso3166Alpha2($countryCode)
6973
/**
7074
* @param string $countryCode
7175
* @return Iso3166Country|null
76+
* @throws Iso3166CountryException
7277
*/
7378
public static function getByIso3166Alpha3($countryCode)
7479
{
@@ -79,16 +84,18 @@ public static function getByIso3166Alpha3($countryCode)
7984
/**
8085
* @param int $countryCode
8186
* @return Iso3166Country|null
87+
* @throws Iso3166CountryException
8288
*/
8389
public static function getByIso3166Numeric($countryCode)
8490
{
85-
$countryCode = str_pad((string)$countryCode, 3, '0', STR_PAD_LEFT);
86-
return self::getBy(self::ISO3166_NUMERIC, $countryCode);
91+
$countryCodePadded = str_pad((string)$countryCode, 3, '0', STR_PAD_LEFT);
92+
return self::getBy(self::ISO3166_NUMERIC, $countryCodePadded);
8793
}
8894

8995
/**
9096
* @param string $countryCode
9197
* @return Iso3166Country|null
98+
* @throws Iso3166CountryException
9299
*/
93100
public static function getByIso3166v2($countryCode)
94101
{
@@ -99,6 +106,7 @@ public static function getByIso3166v2($countryCode)
99106
/**
100107
* @param string $unitedNationsId
101108
* @return Iso3166Country|null
109+
* @throws Iso3166CountryException
102110
*/
103111
public static function getByUnitedNationsId($unitedNationsId)
104112
{
@@ -109,24 +117,25 @@ public static function getByUnitedNationsId($unitedNationsId)
109117
/**
110118
* @param string $toplevelDomain
111119
* @return Iso3166Country|null
120+
* @throws Iso3166CountryException
112121
*/
113122
public static function getByToplevelDomain($toplevelDomain)
114123
{
115-
$toplevelDomain = trim(strtolower($toplevelDomain), '.');
124+
$toplevelDomain = strtolower(trim($toplevelDomain, '.'));
116125
return self::getBy(self::TOP_LEVEL_DOMAIN, $toplevelDomain);
117126
}
118127

119128
/**
120129
* @param string $identifier
121130
* @param string $code
122131
* @return Iso3166Country|null
123-
* @throws Exception\Iso3166CountryException
132+
* @throws Iso3166CountryException
124133
*/
125134
private static function getBy($identifier, $code)
126135
{
127136
$countryDataList = self::getCountryData();
128137
foreach ($countryDataList as $countryData) {
129-
if ($countryData[$identifier] == $code) {
138+
if ($countryData[$identifier] === $code) {
130139
$iso3166Country = new Iso3166Country();
131140
return $iso3166Country->loadByIso3166CountryInformation($countryData);
132141
}
@@ -161,8 +170,8 @@ public static function validateIso3166Alpha3($countryCode)
161170
*/
162171
public static function validateIso3166Numeric($countryCode)
163172
{
164-
$countryCode = str_pad((string)$countryCode, 3, '0', STR_PAD_LEFT);
165-
return self::validateBy(self::ISO3166_NUMERIC, $countryCode);
173+
$countryCodePadded = str_pad((string)$countryCode, 3, '0', STR_PAD_LEFT);
174+
return self::validateBy(self::ISO3166_NUMERIC, $countryCodePadded);
166175
}
167176

168177
/**
@@ -191,7 +200,7 @@ public static function validateUnitedNationsId($unitedNationsId)
191200
*/
192201
public static function validateToplevelDomain($toplevelDomain)
193202
{
194-
$toplevelDomain = trim(strtolower($toplevelDomain), '.');
203+
$toplevelDomain = strtolower(trim($toplevelDomain, '.'));
195204
return self::validateBy(self::TOP_LEVEL_DOMAIN, $toplevelDomain);
196205
}
197206

@@ -204,7 +213,7 @@ private static function validateBy($identifier, $code)
204213
{
205214
$countryDataList = self::getCountryData();
206215
foreach ($countryDataList as $countryData) {
207-
if ($countryData[$identifier] == $code) {
216+
if ($countryData[$identifier] === $code) {
208217
return true;
209218
}
210219
}
@@ -226,10 +235,10 @@ public static function getSelectOptions(
226235
$countryDataList = self::getCountryData();
227236
$options = array();
228237
foreach ($countryDataList as $countryData) {
229-
$selected = ($countryData[$valueKey] == $selectedValue) ? ' selected="selected"' : '';
238+
$selected = ($countryData[$valueKey] === $selectedValue) ? 'selected="selected"' : '';
230239
$value = $countryData[$valueKey];
231240
$name = $countryData[$nameKey];
232-
$options[] = '<option value="' . $value . '"' . $selected . '>' . $name . '</option>';
241+
$options[] = '<option value="' . $value . '" ' . $selected . '>' . $name . '</option>';
233242
}
234243
return implode(PHP_EOL, $options);
235244
}

‎test/Iso3166CountryInformationTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace Markenwerk\Iso3166Country;
3+
namespace ChromaX\Iso3166Country;
44

55
/**
66
* Class Iso3166CountryInformationTest
77
*
8-
* @package Markenwerk\Iso3166Country
8+
* @package ChromaX\Iso3166Country
99
*/
1010
class Iso3166CountryInformationTest extends \PHPUnit_Framework_TestCase
1111
{
@@ -29,55 +29,55 @@ public function testGetCountries()
2929
$countries = Iso3166CountryInformation::getCountries();
3030
$this->assertArrayHasKey('DE', $countries);
3131
$country = $countries['DE'];
32-
$this->assertInstanceOf('Markenwerk\\Iso3166Country\\Iso3166Country', $country);
32+
$this->assertInstanceOf('ChromaX\\Iso3166Country\\Iso3166Country', $country);
3333
}
3434

3535
public function testGetByIso3166Alpha2()
3636
{
3737
$country = Iso3166CountryInformation::getByIso3166Alpha2('de');
38-
$this->assertInstanceOf('Markenwerk\\Iso3166Country\\Iso3166Country', $country);
38+
$this->assertInstanceOf('ChromaX\\Iso3166Country\\Iso3166Country', $country);
3939
$country = Iso3166CountryInformation::getByIso3166Alpha2('xx');
4040
$this->assertNull($country);
4141
}
4242

4343
public function testGetByIso3166Alpha3()
4444
{
4545
$country = Iso3166CountryInformation::getByIso3166Alpha3('deu');
46-
$this->assertInstanceOf('Markenwerk\\Iso3166Country\\Iso3166Country', $country);
46+
$this->assertInstanceOf('ChromaX\\Iso3166Country\\Iso3166Country', $country);
4747
$country = Iso3166CountryInformation::getByIso3166Alpha3('xxx');
4848
$this->assertNull($country);
4949
}
5050

5151
public function testGetByIso3166Numeric()
5252
{
5353
$country = Iso3166CountryInformation::getByIso3166Numeric(276);
54-
$this->assertInstanceOf('Markenwerk\\Iso3166Country\\Iso3166Country', $country);
54+
$this->assertInstanceOf('ChromaX\\Iso3166Country\\Iso3166Country', $country);
5555
$country = Iso3166CountryInformation::getByIso3166Numeric('276');
56-
$this->assertInstanceOf('Markenwerk\\Iso3166Country\\Iso3166Country', $country);
56+
$this->assertInstanceOf('ChromaX\\Iso3166Country\\Iso3166Country', $country);
5757
$country = Iso3166CountryInformation::getByIso3166Numeric(20000);
5858
$this->assertNull($country);
5959
}
6060

6161
public function testGetByIso3166_2()
6262
{
6363
$country = Iso3166CountryInformation::getByIso3166v2('de');
64-
$this->assertInstanceOf('Markenwerk\\Iso3166Country\\Iso3166Country', $country);
64+
$this->assertInstanceOf('ChromaX\\Iso3166Country\\Iso3166Country', $country);
6565
$country = Iso3166CountryInformation::getByIso3166v2('xx');
6666
$this->assertNull($country);
6767
}
6868

6969
public function testGetByToplevelDomain()
7070
{
7171
$country = Iso3166CountryInformation::getByToplevelDomain('de');
72-
$this->assertInstanceOf('Markenwerk\\Iso3166Country\\Iso3166Country', $country);
72+
$this->assertInstanceOf('ChromaX\\Iso3166Country\\Iso3166Country', $country);
7373
$country = Iso3166CountryInformation::getByToplevelDomain('xx');
7474
$this->assertNull($country);
7575
}
7676

7777
public function testGetByUnitedNationsIdentifier()
7878
{
7979
$country = Iso3166CountryInformation::getByUnitedNationsId('de');
80-
$this->assertInstanceOf('Markenwerk\\Iso3166Country\\Iso3166Country', $country);
80+
$this->assertInstanceOf('ChromaX\\Iso3166Country\\Iso3166Country', $country);
8181
$country = Iso3166CountryInformation::getByUnitedNationsId('xx');
8282
$this->assertNull($country);
8383
}

0 commit comments

Comments
 (0)
Please sign in to comment.