Skip to content

Commit d4cef0a

Browse files
authored
Lower the minimum PHP version to PHP 7.0. (#11)
* Downgrade to allow for PHP 7.0 * Fix PH P 7.0 * Fix ? operator * Fix * Add test for number properties * Cleanup * Cleanup * Cleanup
1 parent 1f03fa6 commit d4cef0a

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: php
22

33
php:
4+
- '7.0'
45
- '7.1'
56
- '7.2'
67

composer.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"name": "nekman/luhn-algorithm",
33
"type": "library",
44
"description": "Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.",
5+
"prefer-stable": true,
6+
"prefer-lowest": true,
7+
"minimum-stability": "stable",
58
"keywords": [
69
"luhn",
710
"credit",
@@ -31,10 +34,10 @@
3134
}
3235
},
3336
"require": {
34-
"php": "^7.1"
37+
"php": "^7.0"
3538
},
3639
"require-dev": {
37-
"phpunit/phpunit": "^6.5",
38-
"friendsofphp/php-cs-fixer": "^2.10"
40+
"phpunit/phpunit": "^6.0",
41+
"friendsofphp/php-cs-fixer": "^2.0"
3942
}
4043
}

src/Contract/NumberInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ public function getNumber(): string;
4444
*
4545
* @return int|null The check digit or null if it has not been calculated yet.
4646
*/
47-
public function getCheckDigit(): ?int;
47+
public function getCheckDigit();
4848
}

src/Number.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
class Number implements NumberInterface
3636
{
3737
/**
38-
* @var int
38+
* @var string
3939
*/
4040
private $number;
4141

@@ -49,7 +49,7 @@ class Number implements NumberInterface
4949
* @param string $number The number.
5050
* @param int|null $checkDigit [Optional] The check digit for the number.
5151
*/
52-
public function __construct(string $number, ?int $checkDigit = null)
52+
public function __construct(string $number, int $checkDigit = null)
5353
{
5454
if (!is_numeric($number)) {
5555
throw new \InvalidArgumentException("Expects \$number to be a number, \"{$number}\" given.");
@@ -95,7 +95,7 @@ public function getNumber(): string
9595
/**
9696
* {@inheritdoc}
9797
*/
98-
public function getCheckDigit(): ?int
98+
public function getCheckDigit()
9999
{
100100
return $this->checkDigit;
101101
}

tests/NumberTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,22 @@ public function provideNew_fail()
9898
['123 ', null, \InvalidArgumentException::class],
9999
];
100100
}
101+
102+
/**
103+
* @dataProvider provideProperties
104+
*/
105+
public function testProperties($input, $checkDigit)
106+
{
107+
$number = new Number($input, $checkDigit);
108+
$this->assertEquals($input, $number->getNumber());
109+
$this->assertEquals($checkDigit, $number->getCheckDigit());
110+
}
111+
112+
public function provideProperties()
113+
{
114+
return [
115+
[123, 1],
116+
[123, null],
117+
];
118+
}
101119
}

0 commit comments

Comments
 (0)