<?php
class Bukku{
    
    function parse_ini_file_custom($filename) {
    $config = [];
    $lines = file($filename, FILE_IGNORE_NEW_LINES);
    foreach ($lines as $line) {
        if (strpos($line, '=') !== false) {
            list($key, $value) = explode('=', $line, 2);
            $config[trim($key)] = trim($value);
        }
    }
    return $config;
    }

    function getToken(){
        // Load environment variables from .env file
        $envFile = __DIR__ . '/../../../.env'; // Adjust the path as needed
        if (file_exists($envFile)) {
            $envVariables = $this->parse_ini_file_custom($envFile);
            if ($envVariables) {
                // Access specific keys
                $bBT = $envVariables['BUKKU_BEARER_TOKEN'];
                return $bBT;
            } else {
                echo "Error parsing .env file.";
                return;
            }
        } else {
            echo ".env file not found.";
            return;
        }
    }
    
    function getBaseURL(){
        // Load environment variables from .env file
        $envFile = __DIR__ . '/../../../.env'; // Adjust the path as needed
        if (file_exists($envFile)) {
            $envVariables = $this->parse_ini_file_custom($envFile);
            if ($envVariables) {
                // Access specific keys
                $baseUrl = $envVariables['BUKKU_BASE_URL'];
                return $baseUrl;
            } else {
                echo "Error parsing .env file.";
                return;
            }
        } else {
            echo ".env file not found.";
            return;
        }
    }
}

?>