Acquia\CloudApi\Client\CloudApi::__construct PHP Method

__construct() private method

Constructor.
private __construct ( $site_name, $stage = NULL, $creds_filename = NULL )
$site_name The name of the site for which credentials should be used.
$stage Optional. If provided a file with the suffix matching the stage will be used rather than the default cloudapi.ini file.
    private function __construct($site_name, $stage = NULL, $creds_filename = NULL)
    {
        if (empty($creds_filename)) {
            $creds_filename = sprintf($this->DEFAULT_CREDS_FILENAME . '.ini', $site_name);
            if (!empty($stage)) {
                // Allow a directory of credential files - each with the stage as
                // the extension.
                $extension = empty($stage) ? 'ini' : $stage;
                $test_file = sprintf($this->DEFAULT_CREDS_FILENAME . '.%s', $site_name, $extension);
                if (file_exists($test_file)) {
                    $creds_filename = $test_file;
                }
            }
        }
        if (empty(CloudApi::$allCreds[$creds_filename])) {
            // Read the .ini file.
            if (file_exists($creds_filename) && is_readable($creds_filename)) {
                CloudApi::$allCreds[$creds_filename] = parse_ini_file($creds_filename, true);
            }
        }
        if (empty(CloudApi::$allCreds[$creds_filename])) {
            throw new CloudApiException(sprintf('CREDENTIALS: Cloud credentials not available (check %s)', $creds_filename));
        }
        $this->creds = CloudApi::$allCreds[$creds_filename];
    }