PHP chatgpt-video-generator 정보
PHP chatgpt-video-generator
본문
https://github.com/bghira/chatgpt-video-generator
| declare(strict_types=1); | |
| use Psr\Log\LoggerInterface; | |
| class AppConfig | |
| { | |
| private LoggerInterface $logger; | |
| private array $config; | |
| public function __construct(LoggerInterface $logger) | |
| { | |
| $this->logger = $logger; | |
| $this->loadConfig(); | |
| } | |
| private function loadConfig(): void | |
| { | |
| try { | |
| $configFile = new SplFileObject(__DIR__ . '/../config/config.json', 'r'); | |
| $configContents = $configFile->fread($configFile->getSize()); | |
| $this->config = json_decode($configContents, true); | |
| } catch (\Exception $exception) { | |
| $this->logger->error('Failed to load the configuration file.', [ | |
| 'exception' => $exception | |
| ]); | |
| throw $exception; | |
| } | |
| } | |
| public function getApiKey(string $className): string | |
| { | |
| if (!isset($this->config[$className])) { | |
| $errorMessage = "API key not found for class {$className}."; | |
| $this->logger->error($errorMessage); | |
| throw new \InvalidArgumentException($errorMessage); | |
| } | |
| return $this->config[$className]; | |
| } | |
| } |
그누보드강좌/영카트강좌 - 기초부터 적용까지 체계적인 영상강좌
By 웹학교
추천
0
0
댓글 0개