Skip to content

Commit 38e96f3

Browse files
Merge pull request #1 from phpviet/analysis-XlxAxJ
Apply fixes from StyleCI
2 parents e4fa74b + 41b0b93 commit 38e96f3

11 files changed

+25
-47
lines changed

src/Rules/CallableRule.php

-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717
abstract class CallableRule implements Rule
1818
{
19-
2019
/**
2120
* Hổ trợ sử dụng rule dưới dạng extension.
2221
*
@@ -30,5 +29,4 @@ public function __invoke($attribute, $value, $parameters, $validator)
3029
{
3130
return $this->passes($attribute, $value);
3231
}
33-
3432
}

src/Rules/IdVN.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,19 @@
1616
*/
1717
class IdVN extends CallableRule
1818
{
19-
2019
/**
21-
* @inheritDoc
20+
* {@inheritdoc}
2221
*/
2322
public function passes($attribute, $value): bool
2423
{
2524
return Validator::idVN()->validate($value);
2625
}
2726

2827
/**
29-
* @inheritDoc
28+
* {@inheritdoc}
3029
*/
3130
public function message(): string
3231
{
3332
return __('validation.phpviet.id');
3433
}
35-
3634
}

src/Rules/IpVN.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
class IpVN extends CallableRule
1919
{
20-
2120
const IPV4 = BaseIpVN::IPV4;
2221

2322
const IPV6 = BaseIpVN::IPV6;
@@ -38,15 +37,15 @@ public function __construct(?int $version = null)
3837
}
3938

4039
/**
41-
* @inheritDoc
40+
* {@inheritdoc}
4241
*/
4342
public function passes($attribute, $value): bool
4443
{
4544
return Validator::ipVN($this->version)->validate($value);
4645
}
4746

4847
/**
49-
* @inheritDoc
48+
* {@inheritdoc}
5049
*/
5150
public function message(): string
5251
{
@@ -63,5 +62,4 @@ public function message(): string
6362

6463
}
6564
}
66-
6765
}

src/Rules/LandLineVN.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,19 @@
1616
*/
1717
class LandLineVN extends CallableRule
1818
{
19-
2019
/**
21-
* @inheritDoc
20+
* {@inheritdoc}
2221
*/
2322
public function passes($attribute, $value): bool
2423
{
2524
return Validator::landLineVN()->validate($value);
2625
}
2726

2827
/**
29-
* @inheritDoc
28+
* {@inheritdoc}
3029
*/
3130
public function message(): string
3231
{
3332
return __('validation.phpviet.land_line');
3433
}
35-
3634
}

src/Rules/MobileVN.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@
1717
class MobileVN extends CallableRule
1818
{
1919
/**
20-
* @inheritDoc
20+
* {@inheritdoc}
2121
*/
2222
public function passes($attribute, $value): bool
2323
{
2424
return Validator::mobileVN()->validate($value);
2525
}
2626

2727
/**
28-
* @inheritDoc
28+
* {@inheritdoc}
2929
*/
3030
public function message(): string
3131
{
3232
return __('validation.phpviet.mobile');
3333
}
34-
3534
}

src/ServiceProvider.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
*/
2121
class ServiceProvider extends BaseServiceProvider
2222
{
23-
2423
public function boot(): void
2524
{
2625
if (isset($this->app['validator'])) {
27-
2826
foreach ($this->getCallableRules() as $name => $rule) {
2927
$this->app['validator']->extend($name, $rule, $rule->message());
3028
}
@@ -39,7 +37,7 @@ protected function getCallableRules(): array
3937
'id_vn' => $this->app->make(IdVN::class),
4038
'ip_vn' => $this->app->make(IpVN::class),
4139
'ipv4_vn' => $this->app->make(IpVN::class, [IpVN::IPV4]),
42-
'ipv6_vn' => $this->app->make(IpVN::class, [IpVN::IPV6])
40+
'ipv6_vn' => $this->app->make(IpVN::class, [IpVN::IPV6]),
4341
];
4442
}
4543
}

tests/IdVNTest.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
class IdVNTest extends TestCase
1919
{
20-
2120
public function testValidId()
2221
{
2322
$rule = new IdVN();
@@ -26,9 +25,9 @@ public function testValidId()
2625
$this->assertTrue($rule('attribute', $id, null, null));
2726

2827
$validId = $this->app['validator']->validate([
29-
'id' => $id
28+
'id' => $id,
3029
], [
31-
'id' => 'id_vn'
30+
'id' => 'id_vn',
3231
]);
3332
$this->assertEquals($id, array_shift($validId));
3433
}
@@ -41,9 +40,9 @@ public function testInvalidIp()
4140
$this->assertFalse($rule('attribute', $id, null, null));
4241
$this->expectException('Illuminate\Validation\ValidationException');
4342
$this->app['validator']->validate([
44-
'id' => $id
43+
'id' => $id,
4544
], [
46-
'id' => 'id_vn'
45+
'id' => 'id_vn',
4746
]);
4847
}
4948

@@ -56,5 +55,4 @@ public function testCanTranslateErrorMessage()
5655
$rule->passes('attribute', '025479661123123123123!!!');
5756
$this->assertEquals('id', $rule->message());
5857
}
59-
6058
}

tests/IpVNTest.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
class IpVNTest extends TestCase
1919
{
20-
2120
public function testValidCases()
2221
{
2322
$rule = new IpVN();
@@ -37,16 +36,15 @@ public function testValidCases()
3736
$this->assertFalse($ruleV6('attribute', $ipv4, null, null));
3837
$validIps = $this->app['validator']->validate([
3938
'ipv4' => $ipv4,
40-
'ipv6' => $ipv6
39+
'ipv6' => $ipv6,
4140
], [
4241
'ipv4' => 'ip_vn|ipv4_vn',
43-
'ipv6' => 'ip_vn|ipv6_vn'
42+
'ipv6' => 'ip_vn|ipv6_vn',
4443
]);
4544
$this->assertEquals($ipv4, $validIps['ipv4']);
4645
$this->assertEquals($ipv6, $validIps['ipv6']);
4746
}
4847

49-
5048
public function testInvalidCases()
5149
{
5250
$rule = new IpVN();
@@ -55,9 +53,9 @@ public function testInvalidCases()
5553
$this->assertFalse($rule('attribute', $ip, null, null));
5654
$this->expectException('Illuminate\Validation\ValidationException');
5755
$this->app['validator']->validate([
58-
'ip' => $ip
56+
'ip' => $ip,
5957
], [
60-
'ip' => 'ip_vn|ipv4_vn|ipv6_vn'
58+
'ip' => 'ip_vn|ipv4_vn|ipv6_vn',
6159
]);
6260
}
6361

@@ -70,5 +68,4 @@ public function testCanTranslateErrorMessage()
7068
$rule->passes('attribute', '113.173.134.203@');
7169
$this->assertEquals('ip', $rule->message());
7270
}
73-
7471
}

tests/LandLineVNTest.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
class LandLineVNTest extends TestCase
1919
{
20-
2120
public function testValidId()
2221
{
2322
$rule = new LandLineVN();
@@ -26,9 +25,9 @@ public function testValidId()
2625
$this->assertTrue($rule('attribute', $landLine, null, null));
2726

2827
$validLandLine = $this->app['validator']->validate([
29-
'landLine' => $landLine
28+
'landLine' => $landLine,
3029
], [
31-
'landLine' => 'land_line_vn'
30+
'landLine' => 'land_line_vn',
3231
]);
3332
$this->assertEquals($landLine, array_shift($validLandLine));
3433
}
@@ -41,9 +40,9 @@ public function testInvalidIp()
4140
$this->assertFalse($rule('attribute', $landLine, null, null));
4241
$this->expectException('Illuminate\Validation\ValidationException');
4342
$this->app['validator']->validate([
44-
'landLine' => $landLine
43+
'landLine' => $landLine,
4544
], [
46-
'landLine' => 'land_line_vn'
45+
'landLine' => 'land_line_vn',
4746
]);
4847
}
4948

@@ -56,5 +55,4 @@ public function testCanTranslateErrorMessage()
5655
$rule->passes('attribute', '02838574955!!!');
5756
$this->assertEquals('land_line', $rule->message());
5857
}
59-
6058
}

tests/MobileVNTest.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
class MobileVNTest extends TestCase
1919
{
20-
2120
public function testValidId()
2221
{
2322
$rule = new MobileVN();
@@ -26,9 +25,9 @@ public function testValidId()
2625
$this->assertTrue($rule('attribute', $mobile, null, null));
2726

2827
$validMobile = $this->app['validator']->validate([
29-
'mobile' => $mobile
28+
'mobile' => $mobile,
3029
], [
31-
'mobile' => 'mobile_vn'
30+
'mobile' => 'mobile_vn',
3231
]);
3332
$this->assertEquals($mobile, array_shift($validMobile));
3433
}
@@ -41,9 +40,9 @@ public function testInvalidIp()
4140
$this->assertFalse($rule('attribute', $mobile, null, null));
4241
$this->expectException('Illuminate\Validation\ValidationException');
4342
$this->app['validator']->validate([
44-
'mobile' => $mobile
43+
'mobile' => $mobile,
4544
], [
46-
'mobile' => 'mobile_vn'
45+
'mobile' => 'mobile_vn',
4746
]);
4847
}
4948

@@ -56,5 +55,4 @@ public function testCanTranslateErrorMessage()
5655
$rule->passes('attribute', '0909113911!!!');
5756
$this->assertEquals('mobile', $rule->message());
5857
}
59-
6058
}

tests/TestCase.php

-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
*/
1717
class TestCase extends BaseTestCase
1818
{
19-
2019
public function getPackageProviders($app)
2120
{
2221
return ['PHPViet\Laravel\Validation\ServiceProvider'];
2322
}
24-
2523
}

0 commit comments

Comments
 (0)