Skip to content

Commit d5ba2b9

Browse files
authored
Merge pull request #90 from milwad-dev/refactor
[1.x] Refactor
2 parents 8eb0af8 + 7f5c2b6 commit d5ba2b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+161
-438
lines changed

phpunit.xml.dist

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
beStrictAboutTestsThatDoNotTestAnything="false"
6-
bootstrap="vendor/autoload.php"
7-
colors="true"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
11-
processIsolation="false"
12-
stopOnFailure="false"
13-
verbose="true"
14-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
15-
16-
<testsuites>
17-
<testsuite name="Tests">
18-
<directory suffix="Test.php">./tests/</directory>
19-
</testsuite>
20-
</testsuites>
21-
<coverage includeUncoveredFiles="false">
22-
<include>
23-
<directory suffix=".php">src/</directory>
24-
</include>
25-
</coverage>
26-
<php>
27-
<env name="APP_ENV" value="testing" />
28-
</php>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" beStrictAboutTestsThatDoNotTestAnything="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3+
<testsuites>
4+
<testsuite name="Tests">
5+
<directory suffix="Test.php">./tests/</directory>
6+
</testsuite>
7+
</testsuites>
8+
<php>
9+
<env name="APP_ENV" value="testing"/>
10+
</php>
11+
<source>
12+
<include>
13+
<directory suffix=".php">src/</directory>
14+
</include>
15+
</source>
2916
</phpunit>

phpunit.xml.dist.bak

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
beStrictAboutTestsThatDoNotTestAnything="false"
6+
bootstrap="vendor/autoload.php"
7+
colors="true"
8+
convertErrorsToExceptions="true"
9+
convertNoticesToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
processIsolation="false"
12+
stopOnFailure="false"
13+
verbose="true"
14+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
15+
16+
<testsuites>
17+
<testsuite name="Tests">
18+
<directory suffix="Test.php">./tests/</directory>
19+
</testsuite>
20+
</testsuites>
21+
<coverage includeUncoveredFiles="false">
22+
<include>
23+
<directory suffix=".php">src/</directory>
24+
</include>
25+
</coverage>
26+
<php>
27+
<env name="APP_ENV" value="testing" />
28+
</php>
29+
</phpunit>

src/LaravelValidateServiceProvider.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ class LaravelValidateServiceProvider extends ServiceProvider
4040

4141
/**
4242
* Register files.
43-
*
44-
* @return void
4543
*/
46-
public function register()
44+
public function register(): void
4745
{
4846
if ($this->app->runningInConsole()) {
4947
$this->publishLangFiles();
@@ -68,10 +66,8 @@ private function publishLangFiles(): void
6866

6967
/**
7068
* Publish config file.
71-
*
72-
* @return void
7369
*/
74-
private function publishConfigFile()
70+
private function publishConfigFile(): void
7571
{
7672
$this->publishes([
7773
__DIR__.'/../config/laravel-validate.php' => config_path('laravel-validate.php'),

src/Rules/ValidBase64.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,16 @@ class ValidBase64 implements Rule
88
{
99
/**
1010
* Check base64.
11-
*
12-
* @param string $attribute
13-
* @param mixed $value
14-
* @return bool
1511
*/
16-
public function passes($attribute, $value)
12+
public function passes($attribute, $value): bool
1713
{
1814
return base64_encode(base64_decode($value, true)) === $value;
1915
}
2016

2117
/**
2218
* Get the validation error message.
23-
*
24-
* @return string
2519
*/
26-
public function message()
20+
public function message(): string
2721
{
2822
return __('validate.base64');
2923
}

src/Rules/ValidBitcoinAddress.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,17 @@
77
class ValidBitcoinAddress implements Rule
88
{
99
/**
10-
* Check bitcoin address.
11-
*
12-
* @param string $attribute
13-
* @param mixed $value
14-
* @return bool
10+
* Check bitcoin address is valid.
1511
*/
16-
public function passes($attribute, $value)
12+
public function passes($attribute, $value): bool
1713
{
1814
return preg_match('/^(?:bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/', $value);
1915
}
2016

2117
/**
2218
* Get the validation error message.
23-
*
24-
* @return string
2519
*/
26-
public function message()
20+
public function message(): string
2721
{
2822
return __('validate.bitcoin-address');
2923
}

src/Rules/ValidCamelCase.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,16 @@ class ValidCamelCase implements Rule
88
{
99
/**
1010
* Check value is camel case.
11-
*
12-
* @param string $attribute
13-
* @param mixed $value
14-
* @return bool
1511
*/
16-
public function passes($attribute, $value)
12+
public function passes($attribute, $value): bool
1713
{
1814
return preg_match('/^(?:\p{Lu}?\p{Ll}+)(?:\p{Lu}\p{Ll}+)*$/u', $value);
1915
}
2016

2117
/**
2218
* Get the validation error message.
23-
*
24-
* @return string
2519
*/
26-
public function message()
20+
public function message(): string
2721
{
2822
return __('validate.camel-case');
2923
}

src/Rules/ValidCapitalCharWithNumber.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,16 @@ class ValidCapitalCharWithNumber implements Rule
88
{
99
/**
1010
* Check all words are capital & with hyphen & number.
11-
*
12-
* @param string $attribute
13-
* @param mixed $value
14-
* @return bool
1511
*/
16-
public function passes($attribute, $value)
12+
public function passes($attribute, $value): bool
1713
{
1814
return preg_match('/[A-Z]{2,}-\d+/', $value);
1915
}
2016

2117
/**
2218
* Get the validation error message.
23-
*
24-
* @return string
2519
*/
26-
public function message()
20+
public function message(): string
2721
{
2822
return __('validate.capital-char-with-number');
2923
}

src/Rules/ValidCarNumber.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,16 @@ class ValidCarNumber implements Rule
88
{
99
/**
1010
* Check car number is valid.
11-
*
12-
* @param string $attribute
13-
* @param mixed $value
14-
* @return bool
1511
*/
16-
public function passes($attribute, $value)
12+
public function passes($attribute, $value): bool
1713
{
1814
return preg_match('/^[A-Z]{2}[0-9]{2}[A-Z]{2}[0-9]{4}$/', $value);
1915
}
2016

2117
/**
2218
* Get the validation error message.
23-
*
24-
* @return string
2519
*/
26-
public function message()
20+
public function message(): string
2721
{
2822
return __('validate.car-number');
2923
}

src/Rules/ValidCartNumberIran.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@ class ValidCartNumberIran implements Rule
88
{
99
/**
1010
* Check cart number is valid.
11-
*
12-
* @param string $attribute
13-
* @param mixed $value
14-
* @return bool
1511
*/
16-
public function passes($attribute, $value)
12+
public function passes($attribute, $value): bool
1713
{
1814
$cardToArr = str_split($value);
1915
$cardTotal = 0;
@@ -31,10 +27,8 @@ public function passes($attribute, $value)
3127

3228
/**
3329
* Get the validation error message.
34-
*
35-
* @return string
3630
*/
37-
public function message()
31+
public function message(): string
3832
{
3933
return __('validate.cart-number-iran');
4034
}

src/Rules/ValidCreditCard.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@ class ValidCreditCard implements Rule
88
{
99
/**
1010
* Check if the credit card number is valid using the Luhn algorithm.
11-
*
12-
* @param string $attribute
13-
* @param mixed $value
14-
* @return bool
1511
*/
16-
public function passes($attribute, $value)
12+
public function passes($attribute, $value): bool
1713
{
1814
$value = preg_replace('/\D/', '', $value);
1915

@@ -37,10 +33,8 @@ public function passes($attribute, $value)
3733

3834
/**
3935
* Get the validation error message.
40-
*
41-
* @return string
4236
*/
43-
public function message()
37+
public function message(): string
4438
{
4539
return __('validate.credit-card');
4640
}

0 commit comments

Comments
 (0)