Skip to content

Commit e37586e

Browse files
committed
Add option to skip parsing JSON
1 parent 6e3eb79 commit e37586e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Resolver/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function resolve($definition)
8383

8484
$content = file_get_contents($path);
8585

86-
if (pathinfo($path, PATHINFO_EXTENSION) == 'json') {
86+
if ($parse == 'auto' && pathinfo($path, PATHINFO_EXTENSION) == 'json') {
8787
$content = json_decode($content, true);
8888

8989
if (json_last_error() !== JSON_ERROR_NONE) {

test/Resolver/FileTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,11 @@ public function testResolveJson(): void
110110
{
111111
verify($this->resolver->resolve('./_data/sample.json'))->is()->sameAs(['json' => true]);
112112
}
113+
114+
public function testyResolveWithoutParse(): void
115+
{
116+
$definition = new Definition(['file' => './_data/sample.json', 'parse' => 'text']);
117+
118+
verify($this->resolver->resolve($definition))->is()->sameAs('{"json": true}' . PHP_EOL);
119+
}
113120
}

0 commit comments

Comments
 (0)