@@ -59,6 +59,8 @@ final class Configuration extends Collection
5959 * @param bool $detectByHost
6060 * @param string $format
6161 * @return Configuration
62+ * @throws \InvalidArgumentException
63+ * @throws \RangeException
6264 */
6365 public static function makeByEnv ($ locFile , $ baseFile , $ envFile , $ detectByHost = false , $ format = self ::FORMAT_PHP )
6466 {
@@ -91,12 +93,13 @@ public static function makeByEnv($locFile, $baseFile, $envFile, $detectByHost =
9193 * @param mixed $data If mode is 'folder', $data is config folder path
9294 * @param string $format
9395 * @param string $name
96+ * @throws \RuntimeException
9497 */
9598 public function __construct ($ data = null , $ format = self ::FORMAT_PHP , $ name = 'config ' )
9699 {
97100 $ this ->format = $ format ;
98101
99- if (is_string ($ data ) && is_dir ($ data )) {
102+ if (\ is_string ($ data ) && is_dir ($ data )) {
100103 $ this ->mode = self ::MODE_FOLDER ;
101104 $ this ->folderPath = $ data ;
102105 $ data = null ;
@@ -105,7 +108,7 @@ public function __construct($data = null, $format = self::FORMAT_PHP, $name = 'c
105108 if ($ this ->mode === self ::MODE_FOLDER && !is_dir ($ this ->folderPath )) {
106109 throw new RuntimeException ("Config mode is 'folder'. the property 'folderPath' must is a folder path! " );
107110 }
108-
111+
109112 parent ::__construct ($ data , $ this ->format , $ name );
110113 }
111114
@@ -114,6 +117,7 @@ public function __construct($data = null, $format = self::FORMAT_PHP, $name = 'c
114117 * @param string $path
115118 * @param mixed $value
116119 * @return mixed
120+ * @throws \RuntimeException
117121 */
118122 public function set ($ path , $ value )
119123 {
@@ -130,6 +134,7 @@ public function set($path, $value)
130134 * @param string $path
131135 * @param string $default
132136 * @return mixed
137+ * @throws \RuntimeException
133138 */
134139 public function get (string $ path , $ default = null )
135140 {
@@ -140,11 +145,11 @@ public function get(string $path, $default = null)
140145 // if config file not load. load it.
141146 if (!isset ($ this ->data [$ name ])) {
142147 $ file = $ this ->folderPath . "/ {$ name }. {$ this ->format }" ;
143-
148+
144149 if (!is_file ($ file )) {
145150 throw new \RuntimeException ("The want get config file not exist, Name: $ name, File: $ file " );
146151 }
147-
152+
148153 $ this ->data [$ name ] = self ::read ($ file , $ this ->format );
149154 }
150155 }
@@ -212,6 +217,7 @@ public function getFolderPath(): string
212217
213218 /**
214219 * @param string $folderPath
220+ * @throws \InvalidArgumentException
215221 */
216222 public function setFolderPath (string $ folderPath )
217223 {
0 commit comments