mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* Orange Management
|
|
*
|
|
* PHP Version 7.4
|
|
*
|
|
* @package phpOMS\Utils\TaskSchedule
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0
|
|
* @link https://orange-management.org
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace phpOMS\Utils\TaskSchedule;
|
|
|
|
use phpOMS\System\OperatingSystem;
|
|
use phpOMS\System\SystemType;
|
|
|
|
/**
|
|
* Task factory.
|
|
*
|
|
* @package phpOMS\Utils\TaskSchedule
|
|
* @license OMS License 1.0
|
|
* @link https://orange-management.org
|
|
* @since 1.0.0
|
|
*/
|
|
final class TaskFactory
|
|
{
|
|
/**
|
|
* Create task instance.
|
|
*
|
|
* @param string $id Task id
|
|
* @param string $cmd Command to run
|
|
*
|
|
* @return TaskAbstract
|
|
*
|
|
* @throws \Exception This exception is thrown if the operating system is not supported
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function create(string $id = '', string $cmd = '') : TaskAbstract
|
|
{
|
|
switch (OperatingSystem::getSystem()) {
|
|
case SystemType::WIN:
|
|
return new Schedule($id, $cmd);
|
|
case SystemType::LINUX:
|
|
return new CronJob($id, $cmd);
|
|
default:
|
|
throw new \Exception('Unsupported system.');
|
|
}
|
|
}
|
|
}
|