Lint PHP code psr-12, add GH action

This commit is contained in:
Julien Nahum
2024-02-23 11:54:12 +01:00
parent e85e4df7fe
commit 62971a2ef4
226 changed files with 2338 additions and 2144 deletions

View File

@@ -3,25 +3,24 @@
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Support\Str;
class ValidPhoneInputRule implements Rule
{
public ?int $reason = 0;
public function passes($attribute, $value)
{
if (!is_string($value) || !$value) {
if (! is_string($value) || ! $value) {
return false;
}
try {
if(ctype_alpha(substr($value, 0, 2))){ // First 2 will be country code
if (ctype_alpha(substr($value, 0, 2))) { // First 2 will be country code
$value = substr($value, 2);
}
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
$phone = $phoneUtil->parse($value);
$this->reason = $phoneUtil->isPossibleNumberWithReason($phone);
return $this->reason === \libphonenumber\ValidationResult::IS_POSSIBLE;
} catch (\Exception $e) {
return false;