public static function getCommandResult(CommandsExecutionDto $commandsDto) { $result = null; switch ($commandsDto->getCommandName()) { case CommandsConstants::GET_PID_LOAD_INFO: $result = self::getPidLoadInfo($commandsDto->getPid()); break; case CommandsConstants::GET_MEM_FREE: $result = self::getMemFree(); break; case CommandsConstants::GET_CPU_IDLE: $result = self::getCpuIdle(); break; case CommandsConstants::GET_PID_BY_PPID: $result = self::getPidByPpid($commandsDto->getPid()); break; case CommandsConstants::SEND_SIG: $result = self::sendSig($commandsDto->getPid(), $commandsDto->getSig()); break; case CommandsConstants::GET_CORE_NUMBER: $result = self::getCoreNumber(); break; case CommandsConstants::IS_PROCESS_NAME_RUNNING: $result = self::isProcessNameRunning($commandsDto->getProcessName()); break; default: throw new CommandsExecutionInvalidArgument("Unknown command name."); } return $result; }
public function getCoreNumber() { $commandsDto = new CommandsExecutionDto(); $commandsDto->setCommandName(CommandsConstants::GET_CORE_NUMBER); return $this->getCommandExecutionResult($commandsDto); }