2022-12-30 21:54:44 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2020-01-31 19:29:43 +01:00
|
|
|
|
2019-03-29 21:06:34 +01:00
|
|
|
/**
|
|
|
|
* This file is part of MadelineProto.
|
|
|
|
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU Affero General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* @author Daniil Gentili <daniil@daniil.it>
|
2023-01-04 12:43:01 +01:00
|
|
|
* @copyright 2016-2023 Daniil Gentili <daniil@daniil.it>
|
2019-03-29 21:06:34 +01:00
|
|
|
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
|
2019-10-31 15:07:35 +01:00
|
|
|
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
2019-03-29 21:06:34 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace danog\MadelineProto;
|
|
|
|
|
2023-10-01 20:05:04 +02:00
|
|
|
if (class_exists(VoIPServerConfig::class)) {
|
2020-10-27 20:53:13 +01:00
|
|
|
return;
|
|
|
|
}
|
2022-12-08 20:16:40 +01:00
|
|
|
/**
|
|
|
|
* Manages storage of VoIP server config.
|
2023-08-19 18:29:55 +02:00
|
|
|
*
|
|
|
|
* @internal
|
2022-12-08 20:16:40 +01:00
|
|
|
*/
|
2023-01-15 12:05:38 +01:00
|
|
|
final class VoIPServerConfig
|
2022-12-08 20:16:40 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The configuration.
|
|
|
|
*
|
|
|
|
*/
|
2023-01-04 15:13:55 +01:00
|
|
|
private static array $_config = [];
|
2022-12-08 20:16:40 +01:00
|
|
|
/**
|
|
|
|
* The default configuration.
|
|
|
|
*
|
|
|
|
*/
|
2023-01-04 15:13:55 +01:00
|
|
|
private static array $_configDefault = [];
|
2019-03-29 21:06:34 +01:00
|
|
|
/**
|
2022-12-08 20:16:40 +01:00
|
|
|
* Update shared call settings.
|
|
|
|
*
|
|
|
|
* @param array $config The settings
|
2019-03-29 21:06:34 +01:00
|
|
|
*/
|
2022-12-08 20:16:40 +01:00
|
|
|
public static function update(array $config): void
|
2019-03-29 21:06:34 +01:00
|
|
|
{
|
2022-12-08 20:16:40 +01:00
|
|
|
self::$_config = $config;
|
2019-03-29 21:06:34 +01:00
|
|
|
}
|
2022-12-08 20:16:40 +01:00
|
|
|
/**
|
|
|
|
* Get shared call settings.
|
|
|
|
*
|
|
|
|
* @return array The settings
|
|
|
|
*/
|
|
|
|
public static function get(): array
|
|
|
|
{
|
|
|
|
return self::$_config;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Update default shared call settings.
|
|
|
|
*
|
|
|
|
* @param array $configDefault The settings
|
|
|
|
*/
|
|
|
|
public static function updateDefault(array $configDefault): void
|
|
|
|
{
|
|
|
|
self::$_configDefault = $configDefault;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Get default shared call settings.
|
|
|
|
*
|
|
|
|
* @return array The settings
|
|
|
|
*/
|
|
|
|
public static function getDefault(): array
|
|
|
|
{
|
|
|
|
return self::$_configDefault;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Get final settings.
|
|
|
|
*/
|
|
|
|
public static function getFinal(): array
|
|
|
|
{
|
2023-10-01 20:05:04 +02:00
|
|
|
return array_merge(self::$_configDefault, self::$_config);
|
2022-12-08 20:16:40 +01:00
|
|
|
}
|
|
|
|
}
|