Skip to content

Commit a00ad3a

Browse files
authored
Merge pull request #11 from AlaaSarhan/8-configure-travis
8 configure travis
2 parents a939417 + 72e509b commit a00ad3a

File tree

5 files changed

+65
-12
lines changed

5 files changed

+65
-12
lines changed

.travis.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
language: php
2+
3+
php:
4+
- 5.6
5+
- 7.0
6+
- 7.1
7+
- 7.2
8+
- 7.3
9+
- nightly
10+
11+
matrix:
12+
fast_finish: true
13+
allow_failures:
14+
- php: nightly
15+
16+
sudo: false
17+
18+
before_install:
19+
- travis_retry composer self-update
20+
21+
install:
22+
- travis_retry composer require --no-update satooshi/php-coveralls:^1.0
23+
- travis_retry composer install --no-interaction --prefer-source
24+
25+
before_script:
26+
- mkdir -p build/logs
27+
28+
script:
29+
- ./vendor/bin/phpunit
30+
- ./vendor/bin/phpcs -sp
31+
32+
branches:
33+
only:
34+
- master
35+
- next

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
},
1919
"minimum-stability": "stable",
2020
"require": {
21-
"php": ">=5.5"
21+
"php": "^5.6|^7.0"
2222
},
2323
"require-dev": {
24-
"phpunit/phpunit": "^5.5"
24+
"phpunit/phpunit": "^5.7|^6.0",
25+
"squizlabs/php_codesniffer": "^2.3|^3.0"
2526
},
2627
"scripts": {
27-
"test": "phpunit"
28+
"test": "phpunit",
29+
"cs": "phpcs -sp"
2830
}
2931
}

phpcs.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0"?>
2+
<ruleset>
3+
<file>./src</file>
4+
<file>./test</file>
5+
<rule ref="PSR2" />
6+
</ruleset>

src/Flatten.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ class Flatten
1414

1515
/**
1616
* Flattens a variable, possibly traversable, into a one-dimensional array, recursively.
17-
*
17+
*
1818
* Each key (fully-qualified key or FQK) in the returned one-dimensional array is the join of all keys leading to
1919
* each (non-traversable) value, in all dimensions, separated by a given separator.
20-
*
20+
*
2121
* An initial prefix can be optionally provided, but it will not be separated with the specified separator.
22-
*
22+
*
2323
* @param mixed $var
2424
* @param string $separator
2525
* @param string $prefix
2626
* @param int $flags
27-
* @return array One-dimensional array containing all values from all possible traversable dimensions in given input.
27+
* @return array 1-dimensional array containing all values from all possible traversable dimensions in given input.
2828
* @see Flatten::FLAG_NUMERIC_NOT_FLATTENED
2929
*/
3030
public static function flatten($var, $separator = '.', $prefix = '', $flags = 0)
@@ -35,8 +35,8 @@ public static function flatten($var, $separator = '.', $prefix = '', $flags = 0)
3535
}
3636
return $flattened;
3737
}
38-
39-
private static function flattenGenerator($var, $separator, $prefix = '', $flags)
38+
39+
private static function flattenGenerator($var, $separator, $prefix = '', $flags = 0)
4040
{
4141
if (!self::canTraverse($var)) {
4242
yield $prefix => $var;
@@ -66,7 +66,7 @@ private static function canTraverse($var)
6666
private static function filterNumericKeysAndGetValues($var)
6767
{
6868
$values = [];
69-
$var = array_filter($var, function($value, $key) use (&$values) {
69+
$var = array_filter($var, function ($value, $key) use (&$values) {
7070
if (is_int($key)) {
7171
$values[$key] = $value;
7272
return false;

test/FlattenTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace Sarhan\Flatten\Test;
4+
35
use PHPUnit\Framework\TestCase;
46
use Sarhan\Flatten;
57

@@ -98,7 +100,11 @@ public function traversablesProvider()
98100
[ 'a' => 1, '0' => 2, 'b.0' => 3, 'b.c' => 4 ]
99101
],
100102
[
101-
new \ArrayIterator([ 'a' => 1, 'b' => 2, 'c' => [ 'd' => [ 3, 4 ], 'e' => new \ArrayIterator([ 'f' => 5, 'g' => 6 ]) ] ]),
103+
new \ArrayIterator([
104+
'a' => 1,
105+
'b' => 2,
106+
'c' => [ 'd' => [ 3, 4 ], 'e' => new \ArrayIterator([ 'f' => 5, 'g' => 6 ]) ]
107+
]),
102108
[ 'a' => 1, 'b' => 2, 'c.d.0' => 3, 'c.d.1' => 4, 'c.e.f' => 5, 'c.e.g' => 6 ]
103109
]
104110
];
@@ -133,7 +139,11 @@ public function traversablesSeparatorPrefixProvider()
133139
[ 'local/a' => 1, 'local/0' => 2, 'local/b/0' => 3, 'local/b/c' => 4 ]
134140
],
135141
[
136-
new \ArrayIterator([ 'a' => 1, 'b' => 2, 'c' => [ 'd' => [ 3, 4 ], 'e' => new \ArrayIterator([ 'f' => 5, 'g' => 6 ]) ] ]),
142+
new \ArrayIterator([
143+
'a' => 1,
144+
'b' => 2,
145+
'c' => [ 'd' => [ 3, 4 ], 'e' => new \ArrayIterator([ 'f' => 5, 'g' => 6 ]) ]
146+
]),
137147
'',
138148
':',
139149
[ ':a' => 1, ':b' => 2, ':cd0' => 3, ':cd1' => 4, ':cef' => 5, ':ceg' => 6 ]

0 commit comments

Comments
 (0)