PHP chatgpt-video-generator

· 2년 전 · 410

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];
  }
  }

 

그누보드강좌/영카트강좌 - 기초부터 적용까지 체계적인 영상강좌

프로그래밍 실력 확인하기

심심할 때 게임하자
PHP메뉴얼

By 웹학교

|
댓글을 작성하시려면 로그인이 필요합니다.

365ok IT뉴스

+
제목 글쓴이 날짜 조회
2년 전 조회 385
2년 전 조회 376
2년 전 조회 330
2년 전 조회 310
2년 전 조회 504
2년 전 조회 405
2년 전 조회 361
2년 전 조회 659
2년 전 조회 429
2년 전 조회 353
2년 전 조회 502
2년 전 조회 353
2년 전 조회 499
2년 전 조회 804
2년 전 조회 411
2년 전 조회 317
2년 전 조회 397
2년 전 조회 487
2년 전 조회 504
2년 전 조회 344
2년 전 조회 311
2년 전 조회 350
2년 전 조회 318
2년 전 조회 327
2년 전 조회 421
2년 전 조회 520
2년 전 조회 506
2년 전 조회 484
2년 전 조회 695
2년 전 조회 434