diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bef7694 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +/tests export-ignore +.coveralls.yml export-ignore +.docheader export-ignore +.gitignore export-ignore +.php_cs export-ignore +.travis.yml export-ignore +phpunit.xml.dist export-ignore \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 21b13a7..b985f91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ language: php php: - - 5.4 + - 7.1 + - 7.2 before_script: @@ -9,5 +10,5 @@ before_script: - composer --dev install script: - - php ./vendor/bin/phpunit -c ./tests/. + - php ./vendor/bin/phpunit diff --git a/composer.json b/composer.json index 50997ac..95f25f4 100644 --- a/composer.json +++ b/composer.json @@ -16,15 +16,22 @@ "util" ], "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "require-dev" : { - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": ">=7.0" }, "autoload": { - "psr-0": { - "Codeliner\\ArrayReader\\": "src", + "psr-4": { + "Codeliner\\ArrayReader\\": "src" + } + }, + "autoload-dev": { + "psr-4": { "Codeliner\\ArrayReaderTest\\": "tests" } + }, + "scripts": { + "test": "vendor/bin/phpunit -vvv" } } diff --git a/tests/phpunit.xml.dist b/phpunit.xml.dist similarity index 60% rename from tests/phpunit.xml.dist rename to phpunit.xml.dist index 1e1229f..6924ae3 100644 --- a/tests/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,9 +1,9 @@ - + - ./Codeliner/ArrayReaderTest + ./tests \ No newline at end of file diff --git a/src/Codeliner/ArrayReader/ArrayReader.php b/src/ArrayReader.php similarity index 70% rename from src/Codeliner/ArrayReader/ArrayReader.php rename to src/ArrayReader.php index 0df4f72..ef0207b 100644 --- a/src/Codeliner/ArrayReader/ArrayReader.php +++ b/src/ArrayReader.php @@ -22,7 +22,7 @@ class ArrayReader /** * @var array */ - private $originalArray = array(); + private $originalArray = []; /** * @param array $anArray @@ -32,12 +32,7 @@ public function __construct(array $anArray) $this->originalArray = $anArray; } - /** - * @param string $aPath - * @param int $default - * @return int - */ - public function integerValue($aPath, $default = 0) + public function integerValue(string $aPath, int $default = 0): int { $value = $this->getValueFromPath($aPath); @@ -48,12 +43,7 @@ public function integerValue($aPath, $default = 0) return \intval($value); } - /** - * @param string $aPath - * @param float $default - * @return float - */ - public function floatValue($aPath, $default = 0.0) + public function floatValue(string $aPath, float $default = 0.0): float { $value = $this->getValueFromPath($aPath); @@ -64,12 +54,7 @@ public function floatValue($aPath, $default = 0.0) return \floatval($value); } - /** - * @param string $aPath - * @param bool $default - * @return bool - */ - public function booleanValue($aPath, $default = false) + public function booleanValue(string $aPath, bool $default = false): bool { $value = $this->getValueFromPath($aPath); @@ -80,12 +65,7 @@ public function booleanValue($aPath, $default = false) return (bool)$value; } - /** - * @param string $aPath - * @param string $default - * @return string - */ - public function stringValue($aPath, $default = '') + public function stringValue(string $aPath, string $default = ''): string { $value = $this->getValueFromPath($aPath); @@ -96,12 +76,7 @@ public function stringValue($aPath, $default = '') return \strval($value); } - /** - * @param string $aPath - * @param array $default - * @return array - */ - public function arrayValue($aPath, array $default = array()) + public function arrayValue(string $aPath, array $default = []): array { $value = $this->getValueFromPath($aPath); @@ -122,10 +97,10 @@ public function arrayValue($aPath, array $default = array()) /** * @param string $aPath - * @param null $default + * @param mixed $default * @return mixed */ - public function mixedValue($aPath, $default = null) + public function mixedValue(string $aPath, $default = null) { $value = $this->getValueFromPath($aPath); @@ -136,19 +111,12 @@ public function mixedValue($aPath, $default = null) return $value; } - /** - * @return array - */ - public function toArray() + public function toArray(): array { return $this->originalArray; } - /** - * @param string $aPath - * @return array - */ - protected function toPathKeys($aPath) + protected function toPathKeys(string $aPath): array { $aPath = str_replace('\.', '___IamADot___', $aPath); $parts = explode('.', $aPath); @@ -160,7 +128,7 @@ protected function toPathKeys($aPath) * @param string $aPath * @return mixed */ - protected function getValueFromPath($aPath) + protected function getValueFromPath(string $aPath) { $pathKeys = $this->toPathKeys($aPath); diff --git a/tests/Codeliner/ArrayReaderTest/ArrayReaderTest.php b/tests/ArrayReaderTest.php similarity index 99% rename from tests/Codeliner/ArrayReaderTest/ArrayReaderTest.php rename to tests/ArrayReaderTest.php index c7e0298..c10c852 100644 --- a/tests/Codeliner/ArrayReaderTest/ArrayReaderTest.php +++ b/tests/ArrayReaderTest.php @@ -11,6 +11,7 @@ namespace Codeliner\ArrayReaderTest; use Codeliner\ArrayReader\ArrayReader; +use PHPUnit\Framework\TestCase; /** * Class ArrayReaderTest @@ -18,7 +19,7 @@ * @package Codeliner\ArrayReaderTest * @author Alexander Miertsch */ -class ArrayReaderTest extends \PHPUnit_Framework_TestCase +class ArrayReaderTest extends TestCase { /** * @test