30 lines
911 B
PHP
30 lines
911 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace MintyPHP\Service\User;
|
||
|
|
|
||
|
|
use MintyPHP\Repository\User\UserLifecyclePolicyDashboardRepositoryInterface;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Computes the "Pending deletion" KPI for the user lifecycle settings dashboard.
|
||
|
|
*
|
||
|
|
* If either policy threshold (deactivate / delete days) is disabled, the service short-circuits
|
||
|
|
* to 0 without issuing a database query.
|
||
|
|
*
|
||
|
|
* @api
|
||
|
|
*/
|
||
|
|
final class UserLifecyclePolicyDashboardService
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
private readonly UserLifecyclePolicyDashboardRepositoryInterface $userLifecyclePolicyDashboardRepository
|
||
|
|
) {
|
||
|
|
}
|
||
|
|
|
||
|
|
public function pendingDeletionCount(int $deactivateDays, int $deleteDays, int $windowDays = 7): int
|
||
|
|
{
|
||
|
|
if ($deactivateDays <= 0 || $deleteDays <= 0 || $windowDays <= 0) {
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
return $this->userLifecyclePolicyDashboardRepository->countPendingDeletion($deleteDays, $windowDays);
|
||
|
|
}
|
||
|
|
}
|