mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
51 lines
1020 B
PHP
Executable File
51 lines
1020 B
PHP
Executable File
<?php
|
|
/**
|
|
* Jingga
|
|
*
|
|
* PHP Version 8.1
|
|
*
|
|
* @package phpOMS\Utils\TaskSchedule
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 2.0
|
|
* @version 1.0.0
|
|
* @link https://jingga.app
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace phpOMS\Utils\TaskSchedule;
|
|
|
|
use phpOMS\System\OperatingSystem;
|
|
use phpOMS\System\SystemType;
|
|
|
|
/**
|
|
* Scheduler factory.
|
|
*
|
|
* @package phpOMS\Utils\TaskSchedule
|
|
* @license OMS License 2.0
|
|
* @link https://jingga.app
|
|
* @since 1.0.0
|
|
*/
|
|
final class SchedulerFactory
|
|
{
|
|
/**
|
|
* Create scheduler instance.
|
|
*
|
|
* @return SchedulerAbstract
|
|
*
|
|
* @throws \Exception
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function create() : SchedulerAbstract
|
|
{
|
|
switch (OperatingSystem::getSystem()) {
|
|
case SystemType::WIN:
|
|
return new TaskScheduler();
|
|
case SystemType::LINUX:
|
|
return new Cron();
|
|
default:
|
|
throw new \Exception('Unsupported system.');
|
|
}
|
|
}
|
|
}
|