mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 04:23:59 +00:00
31 lines
700 B
PHP
31 lines
700 B
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Companies\Services;
|
|
|
|
|
|
class GeneratesUniqueAccountNumber
|
|
{
|
|
|
|
/** @var ChecksIfCompanyAccountNumberExists */
|
|
private $accountNumberExists;
|
|
|
|
/**
|
|
* GeneratesUniqueAccountNumber constructor.
|
|
* @param ChecksIfCompanyAccountNumberExists $accountNumberExists
|
|
*/
|
|
public function __construct(ChecksIfCompanyAccountNumberExists $accountNumberExists)
|
|
{
|
|
$this->accountNumberExists = $accountNumberExists;
|
|
}
|
|
|
|
/**
|
|
* @return int
|
|
*/
|
|
public function execute(): int {
|
|
|
|
$number = mt_rand(100000001, 999999999);
|
|
return !$this->accountNumberExists->execute($number) ? $number : self::execute();
|
|
|
|
}
|
|
|
|
} |