Skip to content

Commit c18abce

Browse files
committed
Rename integer to digits
1 parent 126cabb commit c18abce

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Checks if the value contains anything but letters, numbers, and `.-_`.
4646
***
4747

4848
```php
49-
Regex::isInteger($subject, $allowWhitespace = false)
49+
Regex::isDigits($subject, $allowWhitespace = false)
5050
```
5151
Checks if the value contains anything but integers.
5252

@@ -87,7 +87,7 @@ Replaces all characters in the subject except letters, numbers, and `.-_`.
8787
***
8888

8989
```php
90-
Regex::integer($subject, $replace = '')
90+
Regex::digits($subject, $replace = '')
9191
```
9292
Replaces all characters in the subject except integers.
9393

src/Regex.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Regex
1111
const PATTERN_ALPHA = '\pL\pM';
1212
const PATTERN_ALPHANUMERIC = '\pL\pM\pN';
1313
const PATTERN_ALPHADASH = '\pL\pM\pN._-';
14-
const PATTERN_INTEGER = '\pN';
14+
const PATTERN_DIGITS = '0-9';
1515
const PATTERN_NUMERIC = '-?\d*(\.\d+)?';
1616

1717
/**
@@ -57,9 +57,9 @@ public static function alphanumeric($subject, $replace = '')
5757
* @param string $replace
5858
* @return array|string|string[]|null
5959
*/
60-
public static function integer($subject, $replace = '')
60+
public static function digits($subject, $replace = '')
6161
{
62-
return static::replace($subject, self::PATTERN_INTEGER, $replace);
62+
return static::replace($subject, self::PATTERN_DIGITS, $replace);
6363
}
6464

6565
/**
@@ -128,9 +128,9 @@ public static function isAlphanumeric($subject, bool $allowWhitespace = false)
128128
* @param bool $allowWhitespace
129129
* @return bool
130130
*/
131-
public static function isInteger($subject, bool $allowWhitespace = false)
131+
public static function isDigits($subject, bool $allowWhitespace = false)
132132
{
133-
return static::match($subject, self::PATTERN_INTEGER, $allowWhitespace);
133+
return static::match($subject, self::PATTERN_DIGITS, $allowWhitespace);
134134
}
135135

136136
/**

tests/RegexTest.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ public function providesReplacementSubjects()
3737
'AbČdë12345.-_',
3838
],
3939

40-
'replace non integer' => [
41-
'integer',
40+
'replace non digits' => [
41+
'digits',
4242
'12345',
4343
],
4444

45+
'replace non numeric' => [
46+
'numeric',
47+
'12345.-*',
48+
],
49+
4550
];
4651
}
4752

@@ -153,29 +158,29 @@ public function providesMatchSubjects()
153158
$invalid,
154159
],
155160

156-
'match integer' => [
157-
'isInteger',
161+
'match digits' => [
162+
'isDigits',
158163
'12345',
159164
$disallowWhitespace,
160165
$valid,
161166
],
162167

163-
'match integer allow whitespace' => [
164-
'isInteger',
168+
'match digits allow whitespace' => [
169+
'isDigits',
165170
'1234 5',
166171
$allowWhitespace,
167172
$valid,
168173
],
169174

170-
'match integer disallow whitespace' => [
171-
'isInteger',
175+
'match digits disallow whitespace' => [
176+
'isDigits',
172177
'1234 5',
173178
$disallowWhitespace,
174179
$invalid,
175180
],
176181

177-
'match non integer' => [
178-
'isInteger',
182+
'match non digits' => [
183+
'isDigits',
179184
'12345A',
180185
$disallowWhitespace,
181186
$invalid,

tests/TestCase.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22

33
namespace Tests;
44

5-
use Hotmeteor\Regex\RegexServiceProvider;
65
use Orchestra\Testbench\TestCase as BaseTestCase;
76

87
abstract class TestCase extends BaseTestCase
98
{
10-
protected function getPackageProviders($app)
11-
{
12-
return [RegexServiceProvider::class];
13-
}
149
}

0 commit comments

Comments
 (0)