Permalink
Browse files

move docblocks to interface, renames

  • Loading branch information...
1 parent a9f0cde commit 7b347b9c4d818dd7240363f5984d34e0b921121b @alcohol alcohol committed Sep 14, 2016
View
@@ -8,7 +8,7 @@ title: Using league/iso3166
### Interface
-The following methods are provided by the `League\ISO3166\DataProvider` interface.
+The following methods are provided by the `League\ISO3166\ISO3166DataProvider` interface.
**Lookup data by alpha2 code:**
View
@@ -1,34 +0,0 @@
-<?php
-
-/*
- * (c) Rob Bast <rob.bast@gmail.com>
- *
- * For the full copyright and license information, please view
- * the LICENSE file that was distributed with this source code.
- */
-
-namespace League\ISO3166;
-
-interface DataProvider
-{
- /**
- * Return data for given alpha2 code.
- *
- * @param string $alpha2
- */
- public function alpha2($alpha2);
-
- /**
- * Return data for given alpha3 code.
- *
- * @param string $alpha3
- */
- public function alpha3($alpha3);
-
- /**
- * Return data for given numeric code.
- *
- * @param string $numeric
- */
- public function numeric($numeric);
-}
View
@@ -9,9 +9,9 @@
namespace League\ISO3166;
-final class ISO3166 implements \Countable, \IteratorAggregate, DataProvider
+final class ISO3166 implements \Countable, \IteratorAggregate, ISO3166DataProvider
{
- use KeyValidators;
+ use ISO3166KeyValidators;
/** @var string */
const KEY_ALPHA2 = 'alpha2';
@@ -32,59 +32,20 @@ public function __construct(array $countries = [])
}
}
- /**
- * Lookup ISO3166-1 data by alpha2 identifier.
- *
- * @api
- *
- * @param string $alpha2
- *
- * @throws \InvalidArgumentException if input is not a string.
- * @throws \DomainException if input does not look like an alpha2 key.
- * @throws \OutOfBoundsException if input does not exist in dataset.
- *
- * @return array
- */
public function alpha2($alpha2)
{
$this->guardAgainstInvalidAlpha2($alpha2);
return $this->lookup(self::KEY_ALPHA2, $alpha2);
}
- /**
- * Lookup ISO3166-1 data by alpha3 identifier.
- *
- * @api
- *
- * @param string $alpha3
- *
- * @throws \InvalidArgumentException if input is not a string.
- * @throws \DomainException if input does not look like an alpha3 key.
- * @throws \OutOfBoundsException if input does not exist in dataset.
- *
- * @return array
- */
public function alpha3($alpha3)
{
$this->guardAgainstInvalidAlpha3($alpha3);
return $this->lookup(self::KEY_ALPHA3, $alpha3);
}
- /**
- * Lookup ISO3166-1 data by numeric identifier (numerical string, that is).
- *
- * @api
- *
- * @param string $numeric
- *
- * @throws \InvalidArgumentException if input is not a string.
- * @throws \DomainException if input does not look like a numeric key.
- * @throws \OutOfBoundsException if input does not exist in dataset.
- *
- * @return array
- */
public function numeric($numeric)
{
$this->guardAgainstInvalidNumeric($numeric);
@@ -93,8 +54,6 @@ public function numeric($numeric)
}
/**
- * @api
- *
* @return array
*/
public function all()
@@ -103,8 +62,6 @@ public function all()
}
/**
- * @api
- *
* @param string $key
*
* @return \Generator
@@ -0,0 +1,58 @@
+<?php
+
+/*
+ * (c) Rob Bast <rob.bast@gmail.com>
+ *
+ * For the full copyright and license information, please view
+ * the LICENSE file that was distributed with this source code.
+ */
+
+namespace League\ISO3166;
+
+interface ISO3166DataProvider
+{
+ /**
+ * Lookup ISO3166-1 data by alpha2 identifier.
+ *
+ * @api
+ *
+ * @param string $alpha2
+ *
+ * @throws \InvalidArgumentException if input is not a string.
+ * @throws \DomainException if input does not look like an alpha2 key.
+ * @throws \OutOfBoundsException if input does not exist in dataset.
+ *
+ * @return array
+ */
+ public function alpha2($alpha2);
+
+ /**
+ * Lookup ISO3166-1 data by alpha3 identifier.
+ *
+ * @api
+ *
+ * @param string $alpha3
+ *
+ * @throws \InvalidArgumentException if input is not a string.
+ * @throws \DomainException if input does not look like an alpha3 key.
+ * @throws \OutOfBoundsException if input does not exist in dataset.
+ *
+ * @return array
+ */
+ public function alpha3($alpha3);
+
+ /**
+ * Lookup ISO3166-1 data by numeric identifier (numerical string, that is).
+ *
+ * @api
+ *
+ * @param string $numeric
+ *
+ * @throws \InvalidArgumentException if input is not a string.
+ * @throws \DomainException if input does not look like a numeric key.
+ * @throws \OutOfBoundsException if input does not exist in dataset.
+ *
+ * @return array
+ */
+ public function numeric($numeric);
+}
@@ -9,7 +9,7 @@
namespace League\ISO3166;
-final class DataValidator
+final class ISO3166DataValidator
{
use KeyValidators;
@@ -9,7 +9,7 @@
namespace League\ISO3166;
-trait KeyValidators
+trait ISO3166KeyValidators
{
/**
* Assert that input looks like an alpha2 key.
@@ -9,19 +9,23 @@
namespace League\ISO3166;
-class DataValidatorTest extends \PHPUnit_Framework_TestCase
+class ISO3166DataValidatorTest extends \PHPUnit_Framework_TestCase
{
- /** @var DataValidator */
+ /** @var ISO3166DataValidator */
public $validator;
public function setUp()
{
- $this->validator = new DataValidator();
+ $this->validator = new ISO3166DataValidator();
}
/**
* @testdox Assert that each data entry has the required lookup keys.
* @dataProvider testcases
+ *
+ * @param array $data
+ * @param string $expectedException
+ * @param string $exceptionPattern
*/
public function testDataEntryHasRequiredKeys(array $data, $expectedException, $exceptionPattern)
{
@@ -30,7 +30,7 @@ class ISO3166Test extends \PHPUnit_Framework_TestCase
public function setUp()
{
- $validator = new DataValidator();
+ $validator = new ISO3166DataValidator();
$this->iso3166 = new ISO3166($validator->validate([$this->foo, $this->bar]));
}
@@ -39,6 +39,8 @@ public function setUp()
* @dataProvider invalidAlpha2Provider
*
* @param string $alpha2
+ * @param string $expectedException
+ * @param string $exceptionPattern
*/
public function testGetByAlpha2Invalid($alpha2, $expectedException, $exceptionPattern)
{
@@ -79,6 +81,8 @@ public function testGetByAlpha2()
* @dataProvider invalidAlpha3Provider
*
* @param string $alpha3
+ * @param string $expectedException
+ * @param string $exceptionPattern
*/
public function testGetByAlpha3Invalid($alpha3, $expectedException, $exceptionPattern)
{
@@ -119,6 +123,8 @@ public function testGetByAlpha3()
* @dataProvider invalidNumericProvider
*
* @param string $numeric
+ * @param string $expectedException
+ * @param string $exceptionPattern
*/
public function testGetByNumericInvalid($numeric, $expectedException, $exceptionPattern)
{

0 comments on commit 7b347b9

Please sign in to comment.