fix test issues
API CI/CD / Validate (composer + pint) (push) Successful in 3m30s
API CI/CD / Test (PHPUnit) (push) Failing after 5m4s
API CI/CD / Build frontend assets (push) Successful in 1m1s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 3m30s
API CI/CD / Test (PHPUnit) (push) Failing after 5m4s
API CI/CD / Build frontend assets (push) Successful in 1m1s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
class AccountAvailability
|
||||
{
|
||||
public static function isUnavailable(object $user): bool
|
||||
{
|
||||
$status = strtolower(trim((string) ($user->status ?? '')));
|
||||
$isVerified = $user->is_verified ?? null;
|
||||
$isSuspended = $user->is_suspended ?? null;
|
||||
|
||||
return ($status !== '' && $status !== 'active')
|
||||
|| self::isExplicitFalse($isVerified)
|
||||
|| self::isTruthy($isSuspended);
|
||||
}
|
||||
|
||||
public static function isAuthUnavailable(object $user): bool
|
||||
{
|
||||
$status = strtolower(trim((string) ($user->status ?? '')));
|
||||
$isSuspended = $user->is_suspended ?? null;
|
||||
|
||||
return ($status !== '' && $status !== 'active')
|
||||
|| self::isTruthy($isSuspended);
|
||||
}
|
||||
|
||||
private static function isExplicitFalse(mixed $value): bool
|
||||
{
|
||||
return $value === false || $value === 0 || $value === '0';
|
||||
}
|
||||
|
||||
private static function isTruthy(mixed $value): bool
|
||||
{
|
||||
return $value === true || $value === 1 || $value === '1';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user