Skip to content

Commit 5bb91bc

Browse files
committed
set json decode as array
1 parent b1ac552 commit 5bb91bc

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/FileReader.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __construct(string $fileFormat = 'json')
1919
$this->fileFormat = $fileFormat;
2020
}
2121

22-
public function readFile(string $filename, bool $isArray = null): ?array
22+
public function readFile(string $filename, bool $isArray = true): ?array
2323
{
2424
if (file_exists($filename)) {
2525
$fileNameParts = explode(".", $this->normalizeFilename($filename));
@@ -35,10 +35,7 @@ public function readFile(string $filename, bool $isArray = null): ?array
3535
$fileContentArray = $jsonVariables;
3636
}
3737
} elseif ($fileFormat === 'yaml' || $fileFormat === 'yml') {
38-
$handle = fopen($filename, "r");
39-
$yamlVariables = Yaml::parse(fread($handle, self::MAX_FILE_SIZE), Yaml::PARSE_OBJECT_FOR_MAP);
40-
fclose($handle);
41-
$fileContentArray = get_object_vars($yamlVariables);
38+
$fileContentArray = Yaml::parseFile($filename);
4239
} else {
4340
throw new DifferException("unknown files format: use json, yaml (yml) enstead\n");
4441
}

0 commit comments

Comments
 (0)