Skip to content

Commit 543413a

Browse files
committed
feat(config): add EnvironmentConfig DTO
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent 8785f14 commit 543413a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/Config/EnvironmentConfig.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
// SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
4+
// SPDX-License-Identifier: AGPL-3.0-or-later
5+
6+
declare(strict_types=1);
7+
8+
namespace LibreCodeCoop\NfsePHP\Config;
9+
10+
/**
11+
* Immutable configuration for the NFS-e environment (sandbox vs. production).
12+
*
13+
* When no custom base URL is supplied the appropriate official endpoint is
14+
* selected automatically from the sandboxMode flag:
15+
*
16+
* - Production: https://nfse.fazenda.gov.br/NFS-e/api/v1
17+
* - Sandbox: https://hml.nfse.fazenda.gov.br/NFS-e/api/v1
18+
*/
19+
final readonly class EnvironmentConfig
20+
{
21+
private const BASE_URL_PROD = 'https://nfse.fazenda.gov.br/NFS-e/api/v1';
22+
private const BASE_URL_SANDBOX = 'https://hml.nfse.fazenda.gov.br/NFS-e/api/v1';
23+
24+
public string $baseUrl;
25+
26+
public function __construct(
27+
public bool $sandboxMode = false,
28+
?string $baseUrl = null,
29+
) {
30+
$this->baseUrl = $baseUrl ?? ($sandboxMode
31+
? self::BASE_URL_SANDBOX
32+
: self::BASE_URL_PROD);
33+
}
34+
}

0 commit comments

Comments
 (0)