Skip to content

Commit d7b2317

Browse files
author
Alexander Miertsch
authored
Merge pull request #5 from codeliner/modernisation
Modernization
2 parents c1be1b8 + 990fe2e commit d7b2317

6 files changed

Lines changed: 36 additions & 52 deletions

File tree

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/tests export-ignore
2+
.coveralls.yml export-ignore
3+
.docheader export-ignore
4+
.gitignore export-ignore
5+
.php_cs export-ignore
6+
.travis.yml export-ignore
7+
phpunit.xml.dist export-ignore

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
language: php
22

33
php:
4-
- 5.4
4+
- 7.1
5+
- 7.2
56

67

78
before_script:
89
- composer self-update
910
- composer --dev install
1011

1112
script:
12-
- php ./vendor/bin/phpunit -c ./tests/.
13+
- php ./vendor/bin/phpunit
1314

composer.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,22 @@
1616
"util"
1717
],
1818
"require": {
19-
"php": ">=5.3.3"
19+
"php": ">=7.1"
2020
},
2121
"require-dev" : {
22-
"phpunit/phpunit": "3.7.*"
22+
"phpunit/phpunit": ">=7.0"
2323
},
2424
"autoload": {
25-
"psr-0": {
26-
"Codeliner\\ArrayReader\\": "src",
25+
"psr-4": {
26+
"Codeliner\\ArrayReader\\": "src"
27+
}
28+
},
29+
"autoload-dev": {
30+
"psr-4": {
2731
"Codeliner\\ArrayReaderTest\\": "tests"
2832
}
33+
},
34+
"scripts": {
35+
"test": "vendor/bin/phpunit -vvv"
2936
}
3037
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit bootstrap="bootstrap.php">
3+
<phpunit bootstrap="tests/bootstrap.php">
44
<testsuites>
55
<testsuite name="ArrayReaderTest">
6-
<directory>./Codeliner/ArrayReaderTest</directory>
6+
<directory>./tests</directory>
77
</testsuite>
88
</testsuites>
99
</phpunit>
Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ArrayReader
2222
/**
2323
* @var array
2424
*/
25-
private $originalArray = array();
25+
private $originalArray = [];
2626

2727
/**
2828
* @param array $anArray
@@ -32,12 +32,7 @@ public function __construct(array $anArray)
3232
$this->originalArray = $anArray;
3333
}
3434

35-
/**
36-
* @param string $aPath
37-
* @param int $default
38-
* @return int
39-
*/
40-
public function integerValue($aPath, $default = 0)
35+
public function integerValue(string $aPath, int $default = 0): int
4136
{
4237
$value = $this->getValueFromPath($aPath);
4338

@@ -48,12 +43,7 @@ public function integerValue($aPath, $default = 0)
4843
return \intval($value);
4944
}
5045

51-
/**
52-
* @param string $aPath
53-
* @param float $default
54-
* @return float
55-
*/
56-
public function floatValue($aPath, $default = 0.0)
46+
public function floatValue(string $aPath, float $default = 0.0): float
5747
{
5848
$value = $this->getValueFromPath($aPath);
5949

@@ -64,12 +54,7 @@ public function floatValue($aPath, $default = 0.0)
6454
return \floatval($value);
6555
}
6656

67-
/**
68-
* @param string $aPath
69-
* @param bool $default
70-
* @return bool
71-
*/
72-
public function booleanValue($aPath, $default = false)
57+
public function booleanValue(string $aPath, bool $default = false): bool
7358
{
7459
$value = $this->getValueFromPath($aPath);
7560

@@ -80,12 +65,7 @@ public function booleanValue($aPath, $default = false)
8065
return (bool)$value;
8166
}
8267

83-
/**
84-
* @param string $aPath
85-
* @param string $default
86-
* @return string
87-
*/
88-
public function stringValue($aPath, $default = '')
68+
public function stringValue(string $aPath, string $default = ''): string
8969
{
9070
$value = $this->getValueFromPath($aPath);
9171

@@ -96,12 +76,7 @@ public function stringValue($aPath, $default = '')
9676
return \strval($value);
9777
}
9878

99-
/**
100-
* @param string $aPath
101-
* @param array $default
102-
* @return array
103-
*/
104-
public function arrayValue($aPath, array $default = array())
79+
public function arrayValue(string $aPath, array $default = []): array
10580
{
10681
$value = $this->getValueFromPath($aPath);
10782

@@ -122,10 +97,10 @@ public function arrayValue($aPath, array $default = array())
12297

12398
/**
12499
* @param string $aPath
125-
* @param null $default
100+
* @param mixed $default
126101
* @return mixed
127102
*/
128-
public function mixedValue($aPath, $default = null)
103+
public function mixedValue(string $aPath, $default = null)
129104
{
130105
$value = $this->getValueFromPath($aPath);
131106

@@ -136,19 +111,12 @@ public function mixedValue($aPath, $default = null)
136111
return $value;
137112
}
138113

139-
/**
140-
* @return array
141-
*/
142-
public function toArray()
114+
public function toArray(): array
143115
{
144116
return $this->originalArray;
145117
}
146118

147-
/**
148-
* @param string $aPath
149-
* @return array
150-
*/
151-
protected function toPathKeys($aPath)
119+
protected function toPathKeys(string $aPath): array
152120
{
153121
$aPath = str_replace('\.', '___IamADot___', $aPath);
154122
$parts = explode('.', $aPath);
@@ -160,7 +128,7 @@ protected function toPathKeys($aPath)
160128
* @param string $aPath
161129
* @return mixed
162130
*/
163-
protected function getValueFromPath($aPath)
131+
protected function getValueFromPath(string $aPath)
164132
{
165133
$pathKeys = $this->toPathKeys($aPath);
166134

tests/Codeliner/ArrayReaderTest/ArrayReaderTest.php renamed to tests/ArrayReaderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
namespace Codeliner\ArrayReaderTest;
1212

1313
use Codeliner\ArrayReader\ArrayReader;
14+
use PHPUnit\Framework\TestCase;
1415

1516
/**
1617
* Class ArrayReaderTest
1718
*
1819
* @package Codeliner\ArrayReaderTest
1920
* @author Alexander Miertsch <kontakt@codeliner.ws>
2021
*/
21-
class ArrayReaderTest extends \PHPUnit_Framework_TestCase
22+
class ArrayReaderTest extends TestCase
2223
{
2324
/**
2425
* @test

0 commit comments

Comments
 (0)