403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/landing/lib/Copilot/Generation/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/landing/lib/Copilot/Generation/Error.php
<?php
declare(strict_types=1);

namespace Bitrix\Landing\Copilot\Generation;

use Bitrix\Landing\Copilot\Generation\Type\Errors;
use Bitrix\Main\Localization\Loc;

class Error
{
	private const LANG_PREFIX = 'LANDING_AI_SITE_ERROR_';
	private const DEFAULT_ERROR = 'LANDING_AI_SITE_ERROR';

	public string $code = '';
	public string $message = '';

	public function getMessage(): string
	{
		return "{$this->code}: {$this->message}";
	}

	/**
	 * Arraylize data
	 * @return array
	 */
	public function toArray(): array
	{
		return [
			'code' => $this->code,
			'message' => $this->message,
		];
	}

	/**
	 * Create object from array
	 * @param array $data
	 * @return Error
	 */
	public static function fromArray(array $data): Error
	{
		$dto = new self();
		$dto->code = $data['code'] ?? '';
		$dto->message = $data['message'] ?? '';

		return $dto;
	}

	/**
	 * Get Error DTO with default message by code
	 * @param Errors|null $code - get enumerated code, or null for default Error
	 * @return Error
	 */
	public static function createError(?Errors $code = null): self
	{
		$error = new Error();

		if ($code)
		{
			$error->code = $code->name;
			$error->message = Loc::getMessage(self::LANG_PREFIX . $code->value) ?? '';
		}
		else
		{
			$error->code = self::DEFAULT_ERROR;
		}

		return $error;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit