Skip to content
This repository was archived by the owner on Jan 23, 2019. It is now read-only.

Commit 70c6335

Browse files
committed
some update, code formats
1 parent 52b4c7b commit 70c6335

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1066
-424
lines changed

src/Collections/ActiveData.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function load($data, $recursive = false)
5353
continue;
5454
}
5555

56-
$this->$name = $recursive && is_array($value) ? static::create($value, $recursive) : $value;
56+
$this->$name = $recursive && \is_array($value) ? static::create($value, $recursive) : $value;
5757
}
5858

5959
return $this;
@@ -67,6 +67,7 @@ public function isStrict()
6767
/**
6868
* @param bool $toArray
6969
* @return array|\ArrayIterator
70+
* @throws \ReflectionException
7071
*/
7172
public function all($toArray = false)
7273
{

src/Collections/Collection.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class Collection extends SimpleCollection
7373
* @param mixed $data
7474
* @param string $format
7575
* @param string $name
76+
* @throws \RangeException
7677
*/
7778
public function __construct($data = null, $format = 'php', $name = 'box1')
7879
{
@@ -212,6 +213,7 @@ public function getName()
212213
* @param string|array $data
213214
* @param string $format = 'php'
214215
* @return static
216+
* @throws \RuntimeException
215217
* @throws \RangeException
216218
*/
217219
public function load($data, $format = 'php')
@@ -220,7 +222,7 @@ public function load($data, $format = 'php')
220222
return $this;
221223
}
222224

223-
if (is_string($data) && in_array($format, static::$formats, true)) {
225+
if (\is_string($data) && \in_array($format, static::$formats, true)) {
224226
switch ($format) {
225227
case static::FORMAT_YML:
226228
$this->loadYaml($data);
@@ -240,7 +242,7 @@ public function load($data, $format = 'php')
240242
break;
241243
}
242244

243-
} elseif (is_array($data) || is_object($data)) {
245+
} elseif (\is_array($data) || \is_object($data)) {
244246
$this->bindData($this->data, $data);
245247
}
246248

@@ -272,14 +274,15 @@ public function loadYaml($data)
272274
* load data form php file or array
273275
* @param array|string $data
274276
* @return static
277+
* @throws \InvalidArgumentException
275278
*/
276279
public function loadArray($data)
277280
{
278-
if (is_string($data) && is_file($data)) {
281+
if (\is_string($data) && is_file($data)) {
279282
$data = require $data;
280283
}
281284

282-
if (!is_array($data)) {
285+
if (!\is_array($data)) {
283286
throw new \InvalidArgumentException('param type error! must is array.');
284287
}
285288

@@ -290,10 +293,11 @@ public function loadArray($data)
290293
* load data form php file or array
291294
* @param mixed $data
292295
* @return static
296+
* @throws \InvalidArgumentException
293297
*/
294298
public function loadObject($data)
295299
{
296-
if (!is_object($data)) {
300+
if (!\is_object($data)) {
297301
throw new \InvalidArgumentException('param type error! must is object.');
298302
}
299303

@@ -339,7 +343,7 @@ protected function bindData(&$parent, $data, $raw = false)
339343
continue;
340344
}
341345

342-
if (is_array($value)) {
346+
if (\is_array($value)) {
343347
if (!isset($parent[$key])) {
344348
$parent[$key] = array();
345349
}

src/Collections/Configuration.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
{

src/Collections/SimpleCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function offsetUnset($key)
279279
*/
280280
public function count()
281281
{
282-
return count($this->data);
282+
return \count($this->data);
283283
}
284284

285285
/********************************************************************************

src/Components/DataProxy.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function __call($method, array $args)
4343
* @param string $name
4444
* @param array $args
4545
* @return mixed
46+
* @throws \RuntimeException
4647
*/
4748
public function call(string $name, array $args)
4849
{

0 commit comments

Comments
 (0)