Skip to content

Commit 29d93d7

Browse files
committed
exception when ini file can not be parsed
1 parent d45d645 commit 29d93d7

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
4+
namespace doganoo\PHPUtil\Exception;
5+
6+
7+
class InvalidPropertyStructureException extends \Exception {
8+
9+
}

src/System/SysProperties.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
namespace doganoo\PHPUtil\System;
2727

2828
use doganoo\PHPUtil\Exception\FileNotFoundException;
29+
use doganoo\PHPUtil\Exception\InvalidPropertyStructureException;
2930
use doganoo\PHPUtil\Exception\NoPathException;
3031

3132
/**
@@ -66,6 +67,7 @@ public function read(string $index): string {
6667
* @return array
6768
* @throws FileNotFoundException
6869
* @throws NoPathException
70+
* @throws InvalidPropertyStructureException
6971
*/
7072
private function getProperties(): array {
7173
if (self::$path === null) {
@@ -74,8 +76,10 @@ private function getProperties(): array {
7476
if (!\is_file(self::$path)) {
7577
throw new FileNotFoundException();
7678
}
77-
$result = parse_ini_file(self::$path);
78-
79-
return $result;
79+
$ini = parse_ini_file(self::$path);
80+
if (false === $ini) {
81+
throw new InvalidPropertyStructureException();
82+
}
83+
return $ini;
8084
}
8185
}

0 commit comments

Comments
 (0)