Skip to content

Commit 4f917ed

Browse files
Release version 1.0.2
1 parent 4a4c657 commit 4f917ed

17 files changed

+17
-26
lines changed

.styleci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
preset: recommended
1+
preset: laravel
22

33
disabled:
44
- single_class_element_per_statement

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Tất cả lịch sử tiến trình phát triển thư viện
44

5+
# 1.0.2
6+
7+
- Sữa các câu báo lỗi trong các exception ở mode negative.
8+
59
# 1.0.1
610

711
- Hổ trợ kiểm tra version ip và báo lỗi nếu không hợp lệ.

src/Exceptions/IdVNException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
/**
1414
* @author Vuong Minh <[email protected]>
15-
*
1615
* @since 1.0.0
1716
*/
1817
class IdVNException extends ValidationException
@@ -22,7 +21,7 @@ class IdVNException extends ValidationException
2221
self::STANDARD => '{{name}} must be a valid Viet Nam id number',
2322
],
2423
self::MODE_NEGATIVE => [
25-
self::STANDARD => '{{name}} must be a valid Viet Nam id number',
24+
self::STANDARD => '{{name}} must not be a valid Viet Nam id number',
2625
],
2726
];
2827
}

src/Exceptions/IpVNException.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
/**
1414
* @author Vuong Minh <[email protected]>
15-
*
1615
* @since 1.0.0
1716
*/
1817
class IpVNException extends ValidationException
@@ -24,11 +23,11 @@ class IpVNException extends ValidationException
2423
public static $defaultTemplates = [
2524
self::MODE_DEFAULT => [
2625
self::STANDARD => '{{name}} must be an IP address of Viet Nam',
27-
self::VERSION => '{{name}} must be an IP address version {{version}} of Viet Nam',
26+
self::VERSION => '{{name}} must not be an IP address version {{version}} of Viet Nam',
2827
],
2928
self::MODE_NEGATIVE => [
3029
self::STANDARD => '{{name}} must be an IP address of Viet Nam',
31-
self::VERSION => '{{name}} must be an IP address version {{version}} of Viet Nam',
30+
self::VERSION => '{{name}} must not be an IP address version {{version}} of Viet Nam',
3231
],
3332
];
3433

src/Exceptions/LandLineVNException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
/**
1414
* @author Vuong Minh <[email protected]>
15-
*
1615
* @since 1.0.0
1716
*/
1817
class LandLineVNException extends ValidationException
@@ -22,7 +21,7 @@ class LandLineVNException extends ValidationException
2221
self::STANDARD => '{{name}} must be a valid Viet Nam land line phone number',
2322
],
2423
self::MODE_NEGATIVE => [
25-
self::STANDARD => '{{name}} must be a valid Viet Nam land line phone number',
24+
self::STANDARD => '{{name}} must not be a valid Viet Nam land line phone number',
2625
],
2726
];
2827
}

src/Exceptions/MobileVNException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
/**
1414
* @author Vuong Minh <[email protected]>
15-
*
1615
* @since 1.0.0
1716
*/
1817
class MobileVNException extends ValidationException
@@ -22,7 +21,7 @@ class MobileVNException extends ValidationException
2221
self::STANDARD => '{{name}} must be a valid Viet Nam mobile phone number',
2322
],
2423
self::MODE_NEGATIVE => [
25-
self::STANDARD => '{{name}} must be a valid Viet Nam mobile phone number',
24+
self::STANDARD => '{{name}} must not be a valid Viet Nam mobile phone number',
2625
],
2726
];
2827
}

src/Rules/AbstractStaticRegexRule.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212

1313
/**
1414
* @author Vuong Minh <[email protected]>
15-
*
1615
* @since 1.0.0
1716
*/
1817
abstract class AbstractStaticRegexRule extends AbstractRegexRule
1918
{
20-
protected function getPregFormat()
19+
protected function getPregFormat(): string
2120
{
2221
return static::pregFormat();
2322
}

src/Rules/IdVN.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
/**
1212
* @author Vuong Minh <[email protected]>
13-
*
1413
* @since 1.0.0
1514
*/
1615
class IdVN extends AbstractStaticRegexRule

src/Rules/IpVN.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
/**
1818
* @author Vuong Minh <[email protected]>
19-
*
2019
* @since 1.0.0
2120
*/
2221
class IpVN extends AbstractRule
@@ -36,7 +35,7 @@ public function __construct(?int $version = null)
3635
$this->version = $version;
3736
}
3837

39-
public function validate($input)
38+
public function validate($input): bool
4039
{
4140
if (!$ip = IpFactory::addressFromString($input)) {
4241
return false;
@@ -72,9 +71,11 @@ protected function getIpRanges(string $ip, int $version): ?array
7271

7372
return $map['range'] ?? null;
7473
}
74+
75+
return null;
7576
}
7677

77-
protected function validateIpInRange(IpInterface $ip, array $ranges)
78+
protected function validateIpInRange(IpInterface $ip, array $ranges): bool
7879
{
7980
foreach ($ranges as $range) {
8081
[$begin, $end] = $range;
@@ -92,7 +93,7 @@ protected static function getIpV4Range(): array
9293
static $range = null;
9394

9495
if (null === $range) {
95-
$range = require __DIR__.'/../../resources/ip-v4-range.php';
96+
$range = require __DIR__ . '/../../resources/ip-v4-range.php';
9697
}
9798

9899
return $range;
@@ -103,7 +104,7 @@ protected static function getIpV6Range(): array
103104
static $range = null;
104105

105106
if (null === $range) {
106-
$range = require __DIR__.'/../../resources/ip-v6-range.php';
107+
$range = require __DIR__ . '/../../resources/ip-v6-range.php';
107108
}
108109

109110
return $range;

src/Rules/LandLineVN.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
/**
1212
* @author Vuong Minh <[email protected]>
13-
*
1413
* @since 1.0.0
1514
*/
1615
class LandLineVN extends AbstractStaticRegexRule

src/Rules/MobileVN.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
/**
1212
* @author Vuong Minh <[email protected]>
13-
*
1413
* @since 1.0.0
1514
*/
1615
class MobileVN extends AbstractStaticRegexRule

src/Validator.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
* @method static Validator idVN()
1919
*
2020
* @author Vuong Minh <[email protected]>
21-
*
2221
* @since 1.0.0
2322
*/
2423
class Validator extends BaseValidator

tests/Rules/IdVNTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
/**
1515
* @author Vuong Minh <[email protected]>
16-
*
1716
* @since 1.0.0
1817
*/
1918
class IdVNTest extends TestCase

tests/Rules/IpVNTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
/**
1515
* @author Vuong Minh <[email protected]>
16-
*
1716
* @since 1.0.0
1817
*/
1918
class IpVNTest extends TestCase

tests/Rules/LandLineVNTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
/**
1515
* @author Vuong Minh <[email protected]>
16-
*
1716
* @since 1.0.0
1817
*/
1918
class LandLineVNTest extends TestCase

tests/Rules/MobileVNTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
/**
1515
* @author Vuong Minh <[email protected]>
16-
*
1716
* @since 1.0.0
1817
*/
1918
class MobileVNTest extends TestCase

tests/ValidatorTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
/**
1616
* @author Vuong Minh <[email protected]>
17-
*
1817
* @since 1.0.0
1918
*/
2019
class ValidatorTest extends TestCase

0 commit comments

Comments
 (0)