1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-27 17:00:52 +01:00
vichan/inc/context.php
2024-03-21 15:14:13 +01:00

29 lines
565 B
PHP

<?php
namespace Vichan;
defined('TINYBOARD') or exit;
use Vichan\Driver\{HttpDriver, HttpDrivers};
interface Context {
public function getHttpDriver(): HttpDriver;
}
class AppContext implements Context {
private array $config;
private ?HttpDriver $http;
public function __construct(array $config) {
$this->config = $config;
}
public function getHttpDriver(): HttpDriver {
if (is_null($this->http)) {
$this->http = HttpDrivers::getHttpDriver($this->config['upload_by_url_timeout'], $this->config['max_filesize']);
}
return $this->http;
}
}