Skip to content

Commit 8335a86

Browse files
- Changed namespace from Codemonster to Codemonster\Env
- Added tests for single and double quoted values in .env - Ensured consistent autoloading with PSR-4.
1 parent 77497b0 commit 8335a86

File tree

6 files changed

+35
-4
lines changed

6 files changed

+35
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project follows [Semantic Versioning](https://semver.org/lang/ru/).
77

88
## [Unreleased]
99

10+
## [1.1.1] - 2025-09-24
11+
12+
### Changed
13+
14+
- Namespace changed from `Codemonster` to `Codemonster\Env`.
15+
- Added support for tests with single and double quotes (`'...'` and `"..."`) in `.env`.
16+
1017
## [1.1.0] - 2025-09-23
1118

1219
### Added
@@ -33,5 +40,6 @@ and this project follows [Semantic Versioning](https://semver.org/lang/ru/).
3340
---
3441

3542
[Unreleased]: https://github.com/codemonster-ru/env-php/compare/v1.1.0...HEAD
43+
[1.1.1]: https://github.com/codemonster-ru/env-php/compare/v1.1.0...v1.1.1
3644
[1.1.0]: https://github.com/codemonster-ru/env-php/compare/v1.0.0...v1.1.0
3745
[1.0.0]: https://github.com/codemonster-ru/env-php/releases/tag/v1.0.0

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
],
1515
"autoload": {
1616
"psr-4": {
17-
"Codemonster\\": "src/"
17+
"Codemonster\\Env\\": "src/"
1818
},
1919
"files": [
2020
"src/helpers.php"

src/Env.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Codemonster;
3+
namespace Codemonster\Env;
44

55
class Env
66
{

src/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
use Codemonster\Env;
3+
use Codemonster\Env\Env;
44

55
if (!function_exists('env')) {
66
function env(string $key, mixed $default = null): mixed

tests/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ OPTIONAL_VALUE=null
77
EMPTY_VALUE=empty
88

99
SSR_URL="http://localhost:3000"
10+
11+
QUOTED_SINGLE='Hello Single'
12+
QUOTED_DOUBLE="Hello Double"

tests/EnvTest.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
<?php
22

3-
use Codemonster\Env;
3+
use Codemonster\Env\Env;
44
use PHPUnit\Framework\TestCase;
55

66
class EnvTest extends TestCase
77
{
88
protected function setUp(): void
99
{
10+
foreach ([
11+
'APP_NAME',
12+
'FEATURE_ENABLED',
13+
'FEATURE_DISABLED',
14+
'OPTIONAL_VALUE',
15+
'EMPTY_VALUE',
16+
'SSR_URL',
17+
'QUOTED_SINGLE',
18+
'QUOTED_DOUBLE'
19+
] as $key) {
20+
unset($_ENV[$key], $_SERVER[$key]);
21+
putenv($key);
22+
}
23+
1024
Env::load(__DIR__ . '/.env.example');
1125
}
1226

@@ -36,6 +50,12 @@ public function testEnvRemovesQuotes(): void
3650
$this->assertSame('http://localhost:3000', env('SSR_URL'));
3751
}
3852

53+
public function testEnvHandlesSingleAndDoubleQuotes(): void
54+
{
55+
$this->assertSame('Hello Single', env('QUOTED_SINGLE'));
56+
$this->assertSame('Hello Double', env('QUOTED_DOUBLE'));
57+
}
58+
3959
public function testEnvReturnsDefaultIfNotSet(): void
4060
{
4161
$this->assertSame('default', env('NOT_DEFINED', 'default'));

0 commit comments

Comments
 (0)