Skip to content

Commit 5922b9b

Browse files
committed
Updated to today's standards
1 parent 6061aab commit 5922b9b

8 files changed

+346
-316
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.idea
1+
.php_cs.cache
22
composer.lock
33
vendor
44
tests/Report

.travis.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
language: php
22

3-
php:
4-
- 5.5
5-
- 5.6
6-
- 7
7-
- hhvm
3+
matrix:
4+
fast_finish: true
5+
include:
6+
- php: 7.1
7+
- php: 7.2
8+
- php: 7.3
89

9-
before_script:
10-
- curl -s http://getcomposer.org/installer | php
11-
- php composer.phar install --prefer-source --no-interaction --dev
10+
sudo: false
1211

13-
script: phpunit
12+
dist: trusty
13+
14+
cache:
15+
directories:
16+
- $HOME/.composer/cache
17+
18+
install:
19+
- composer install
20+
21+
script:
22+
- composer lint
23+
- composer test

composer.json

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
{
2-
"name": "crazycodr/previous-current-iterator",
3-
"description": "Simple package that offers an iterator used for previous vs current comparison",
4-
"license": "MIT",
5-
"authors": [
6-
{
7-
"name": "Mathieu Dumoulin aka crazycodr",
8-
"homepage": "http://www.crazycoders.net/",
9-
"email": "[email protected]",
10-
"role": "Developer"
2+
"name": "crazycodr/previous-current-iterator",
3+
"description": "Simple package that offers an iterator used for previous vs current comparison",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "Mathieu Dumoulin",
8+
"email": "[email protected]",
9+
"role": "Developer"
10+
}
11+
],
12+
"autoload": {
13+
"psr-4": {
14+
"CrazyCodr\\Iterators\\": "src/"
15+
}
16+
},
17+
"require-dev": {
18+
"friendsofphp/php-cs-fixer": "^2.11",
19+
"phpunit/phpunit": "^7.1"
20+
},
21+
"scripts": {
22+
"test": "vendor/bin/phpunit",
23+
"lint": [
24+
"vendor/bin/php-cs-fixer --diff --dry-run -v fix src",
25+
"vendor/bin/php-cs-fixer --diff --dry-run -v fix tests"
26+
],
27+
"fix": [
28+
"vendor/bin/php-cs-fixer --diff -v fix src",
29+
"vendor/bin/php-cs-fixer --diff -v fix tests"
30+
]
1131
}
12-
],
13-
"autoload": {
14-
"psr-4": {
15-
"CrazyCodr\\Iterators\\": "src/"
16-
}
17-
},
18-
"require-dev": {
19-
"phpunit/phpunit": "4.*"
20-
}
2132
}

phpunit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
>
12+
1313
<testsuites>
1414
<testsuite name="CrazyCodr Compare Iterator Test Suite">
1515
<directory>./tests/</directory>
1616
</testsuite>
1717
</testsuites>
1818

1919
<logging>
20-
<log type="coverage-html" target="tests/Report" charset="UTF-8" lowUpperBound="50" highLowerBound="80"/>
20+
<log type="coverage-html" target="tests/Report" lowUpperBound="50" highLowerBound="80"/>
2121
<log type="coverage-clover" target="tests/Report/coverage.xml"/>
2222
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false"/>
2323
</logging>

src/CurrentNextIterator.php

Lines changed: 84 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -12,93 +12,97 @@
1212
class CurrentNextIterator implements \Iterator
1313
{
1414

15-
/**
16-
* Contains the items to iterate over
17-
*
18-
* @var array
19-
*/
20-
private $items = [];
15+
/**
16+
* Contains the items to iterate over
17+
*
18+
* @var array
19+
*/
20+
private $items = [];
2121

22-
/**
23-
* Contains the current item (previous current) to compare with the next
24-
* @var mixed
25-
*/
26-
private $currentItem = null;
22+
/**
23+
* Contains the current item (previous current) to compare with the next
24+
* @var mixed
25+
*/
26+
private $currentItem = null;
2727

28-
/**
29-
* Contains the current key to compare with the current key
30-
* @var null
31-
*/
32-
private $currentKey = null;
28+
/**
29+
* Contains the current key to compare with the current key
30+
* @var null
31+
*/
32+
private $currentKey = null;
3333

34-
/**
35-
* Contains the next item (next current) to compare with the real current
36-
* @var mixed
37-
*/
38-
private $nextItem = null;
34+
/**
35+
* Contains the next item (next current) to compare with the real current
36+
* @var mixed
37+
*/
38+
private $nextItem = null;
3939

40-
/**
41-
* Contains the next key to compare with the current key
42-
* @var null
43-
*/
44-
private $nextKey = null;
40+
/**
41+
* Contains the next key to compare with the current key
42+
* @var null
43+
*/
44+
private $nextKey = null;
4545

46-
/**
47-
* @param array $data
48-
*/
49-
public function __construct(array $data) {
50-
$this->items = $data;
51-
}
46+
/**
47+
* @param array $data
48+
*/
49+
public function __construct(array $data)
50+
{
51+
$this->items = $data;
52+
}
5253

53-
/**
54-
* @inheritedDoc
55-
*/
56-
public function current() {
57-
return [
58-
'current' => $this->currentItem,
59-
'next' => $this->nextItem
60-
];
61-
}
54+
/**
55+
* @inheritedDoc
56+
*/
57+
public function current()
58+
{
59+
return [
60+
'current' => $this->currentItem,
61+
'next' => $this->nextItem
62+
];
63+
}
6264

63-
/**
64-
* @inheritedDoc
65-
*/
66-
public function next() {
67-
$this->currentItem = current($this->items);
68-
$this->currentKey = key($this->items);
69-
next($this->items);
70-
$this->nextItem = current($this->items);
71-
$this->nextKey = key($this->items);
72-
if($this->nextItem === false)
73-
{
74-
$this->nextItem = null;
75-
$this->nextKey = null;
76-
}
77-
}
65+
/**
66+
* @inheritedDoc
67+
*/
68+
public function next()
69+
{
70+
$this->currentItem = current($this->items);
71+
$this->currentKey = key($this->items);
72+
next($this->items);
73+
$this->nextItem = current($this->items);
74+
$this->nextKey = key($this->items);
75+
if ($this->nextItem === false) {
76+
$this->nextItem = null;
77+
$this->nextKey = null;
78+
}
79+
}
7880

79-
/**
80-
* @inheritedDoc
81-
*/
82-
public function key() {
83-
return [
84-
'previous' => $this->currentKey,
85-
'current' => $this->nextKey
86-
];
87-
}
81+
/**
82+
* @inheritedDoc
83+
*/
84+
public function key()
85+
{
86+
return [
87+
'previous' => $this->currentKey,
88+
'current' => $this->nextKey
89+
];
90+
}
8891

89-
/**
90-
* @inheritedDoc
91-
*/
92-
public function valid() {
93-
return $this->currentKey !== null;
94-
}
92+
/**
93+
* @inheritedDoc
94+
*/
95+
public function valid()
96+
{
97+
return $this->currentKey !== null;
98+
}
9599

96-
/**
97-
* @inheritedDoc
98-
*/
99-
public function rewind() {
100-
reset($this->items);
101-
$this->next();
102-
}
103-
104-
}
100+
/**
101+
* @inheritedDoc
102+
*/
103+
public function rewind()
104+
{
105+
reset($this->items);
106+
$this->next();
107+
}
108+
}

0 commit comments

Comments
 (0)