From 7b551168757187495633bc440c025cfefd74d755 Mon Sep 17 00:00:00 2001 From: parth gohil <4966579+parth391@users.noreply.github.com> Date: Fri, 28 Feb 2025 11:03:50 +0530 Subject: [PATCH 1/6] Fix composer error --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 077a9af..f66d871 100644 --- a/composer.json +++ b/composer.json @@ -40,5 +40,5 @@ "phpunit/phpunit": "^6.3|^9.0|^10.5", "orchestra/testbench": "^3.5|^5.0|^7.0|^9.0" }, - "suggest": [] + "suggest": {} } From 72a0b1f3c5f4ead83238bcad1769eeba7ba05095 Mon Sep 17 00:00:00 2001 From: parth gohil <4966579+parth391@users.noreply.github.com> Date: Fri, 28 Feb 2025 11:05:04 +0530 Subject: [PATCH 2/6] Drop php 7 support --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f66d871..4c01695 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "require": { "illuminate/contracts": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", "illuminate/support": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", - "php": "^7.0|^8.0" + "php": "^8.0" }, "require-dev": { "phpunit/phpunit": "^6.3|^9.0|^10.5", From d0985a28ba1dcc068a545bcb1f87cb3d64eb5dad Mon Sep 17 00:00:00 2001 From: parth gohil <4966579+parth391@users.noreply.github.com> Date: Fri, 28 Feb 2025 11:07:13 +0530 Subject: [PATCH 3/6] Drop laravel below 10 support --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 4c01695..1f8344d 100644 --- a/composer.json +++ b/composer.json @@ -32,8 +32,8 @@ }, "minimum-stability": "stable", "require": { - "illuminate/contracts": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", - "illuminate/support": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/contracts": "^10.0|^11.0", + "illuminate/support": "^10.0|^11.0", "php": "^8.0" }, "require-dev": { From 6fe68ee25a44efce927d4c4fce13257a9d20449b Mon Sep 17 00:00:00 2001 From: parth gohil <4966579+parth391@users.noreply.github.com> Date: Fri, 28 Feb 2025 11:13:40 +0530 Subject: [PATCH 4/6] Update dependencies --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 1f8344d..fc141b2 100644 --- a/composer.json +++ b/composer.json @@ -37,8 +37,8 @@ "php": "^8.0" }, "require-dev": { - "phpunit/phpunit": "^6.3|^9.0|^10.5", - "orchestra/testbench": "^3.5|^5.0|^7.0|^9.0" + "phpunit/phpunit": "^6.3|^9.0|^10.5|^11.0|^12.0", + "orchestra/testbench": "^3.5|^5.0|^7.0|^9.0|^10.0" }, "suggest": {} } From a7566715f63b642351a62664c20487cbb0cfe11e Mon Sep 17 00:00:00 2001 From: parth gohil <4966579+parth391@users.noreply.github.com> Date: Fri, 28 Feb 2025 11:13:44 +0530 Subject: [PATCH 5/6] Update .gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2f89fe5..f7a3e6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ build composer.lock vendor -run.php \ No newline at end of file +run.php +.DS_Store +.phpunit.result.cache From 25bf12ec0491a1a961c7db8844797ed1f7ba54ea Mon Sep 17 00:00:00 2001 From: parth gohil <4966579+parth391@users.noreply.github.com> Date: Fri, 28 Feb 2025 11:41:17 +0530 Subject: [PATCH 6/6] Fix deprecated rule --- src/Digits.php | 27 ++++++++++++--------------- src/E123.php | 28 +++++++++++++--------------- src/E164.php | 29 +++++++++++++---------------- src/NANP.php | 29 +++++++++++++---------------- src/Phone.php | 32 +++++++++++++++----------------- 5 files changed, 66 insertions(+), 79 deletions(-) diff --git a/src/Digits.php b/src/Digits.php index 5b71a2f..4c96293 100644 --- a/src/Digits.php +++ b/src/Digits.php @@ -1,30 +1,27 @@ isDigits($value); - } + protected string $message = ':attribute must be in digits only phone format'; /** - * Get the validation error message. + * Run the validation rule. * - * @return string + * @param string $attribute + * @param mixed $value + * @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail + * @return void */ - public function message() + public function validate(string $attribute, mixed $value, Closure $fail): void { - return ':attribute must be in digits only phone format'; + if (! $this->isDigits($value)) { + $fail($this->message); + } } } diff --git a/src/E123.php b/src/E123.php index 86ac1fa..bf57f2e 100644 --- a/src/E123.php +++ b/src/E123.php @@ -2,29 +2,27 @@ namespace LVR\Phone; +use Closure; class E123 extends Phone { /** - * Determine if the validation rule passes. - * - * @param string $attribute - * @param mixed $value - * - * @return bool + * Validation error message */ - public function passes($attribute, $value) - { - return $this->isE123($value); - } + protected string $message = ':attribute must be in E.123 phone format'; /** - * Get the validation error message. + * Run the validation rule. * - * @return string + * @param string $attribute + * @param mixed $value + * @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail + * @return void */ - public function message() + public function validate(string $attribute, mixed $value, Closure $fail): void { - return ':attribute must be in E.123 phone format'; + if (! $this->isE123($value)) { + $fail($this->message); + } } -} \ No newline at end of file +} diff --git a/src/E164.php b/src/E164.php index a586843..99fc8de 100644 --- a/src/E164.php +++ b/src/E164.php @@ -1,30 +1,27 @@ isE164($value); - } + protected string $message = ':attribute must be in E.164 phone format'; /** - * Get the validation error message. + * Run the validation rule. * - * @return string + * @param string $attribute + * @param mixed $value + * @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail + * @return void */ - public function message() + public function validate(string $attribute, mixed $value, Closure $fail): void { - return ':attribute must be in E.164 phone format'; + if (! $this->isE164($value)) { + $fail($this->message); + } } -} \ No newline at end of file +} diff --git a/src/NANP.php b/src/NANP.php index bdf79de..ac43b52 100644 --- a/src/NANP.php +++ b/src/NANP.php @@ -1,30 +1,27 @@ isNANP($value); - } + protected string $message = ':attribute must be in the NANP phone format'; /** - * Get the validation error message. + * Run the validation rule. * - * @return string + * @param string $attribute + * @param mixed $value + * @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail + * @return void */ - public function message() + public function validate(string $attribute, mixed $value, Closure $fail): void { - return ':attribute must be in the NANP phone format'; + if (! $this->isNANP($value)) { + $fail($this->message); + } } -} \ No newline at end of file +} diff --git a/src/Phone.php b/src/Phone.php index 00a4179..e9e792f 100644 --- a/src/Phone.php +++ b/src/Phone.php @@ -1,31 +1,29 @@ isPhone($value); - } + protected string $message = 'Incorrect phone format for :attribute.'; /** - * Get the validation error message. + * Run the validation rule. * - * @return string + * @param string $attribute + * @param mixed $value + * @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail + * @return void */ - public function message() + public function validate(string $attribute, mixed $value, Closure $fail): void { - return 'Incorrect phone format for :attribute.'; + if (! $this->isPhone($value)) { + $fail($this->message); + } } /** @@ -90,4 +88,4 @@ protected function isNANP($value) $conditions[] = preg_match("/^(?:\+1|1)?\s?-?\(?\d{3}\)?(\s|-)?\d{3}-\d{4}$/i", $value) > 0; return (bool) array_product($conditions); } -} \ No newline at end of file +}