Skip to content
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.

Commit

Permalink
some modify
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jun 6, 2018
1 parent 6871acd commit 7f3d031
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/FileFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static function fromArray(array $config): self
];

foreach ($config as $prop => $values) {
if (isset($allowed[$prop])) {
if ($values && isset($allowed[$prop])) {
$method = $allowed[$prop];
$finder->$method($values);
}
Expand Down Expand Up @@ -164,7 +164,9 @@ public function name(string $pattern): self
*/
public function addNames($patterns): self
{
$this->names = \array_merge($this->names, (array)$patterns);
if ($patterns) {
$this->names = \array_merge($this->names, (array)$patterns);
}

return $this;
}
Expand All @@ -186,7 +188,9 @@ public function notName(string $pattern): self
*/
public function addNotNames($patterns): self
{
$this->notNames = array_merge($this->notNames, $patterns);
if ($patterns) {
$this->notNames = \array_merge($this->notNames, (array)$patterns);
}

return $this;
}
Expand All @@ -210,7 +214,9 @@ public function path(string $pattern): self
*/
public function addPaths($patterns): self
{
$this->paths = array_merge($this->paths, $patterns);
if ($patterns) {
$this->paths = \array_merge($this->paths, (array)$patterns);
}

return $this;
}
Expand All @@ -232,7 +238,9 @@ public function notPath(string $pattern): self
*/
public function addNotPaths($patterns): self
{
$this->notPaths = array_merge($this->notPaths, (array)$patterns);
if ($patterns) {
$this->notPaths = \array_merge($this->notPaths, (array)$patterns);
}

return $this;
}
Expand All @@ -243,7 +251,9 @@ public function addNotPaths($patterns): self
*/
public function exclude($dirs): self
{
$this->excludes = array_merge($this->excludes, (array)$dirs);
if ($dirs) {
$this->excludes = \array_merge($this->excludes, (array)$dirs);
}

return $this;
}
Expand Down Expand Up @@ -281,7 +291,7 @@ public function ignoreDotFiles($ignoreDotFiles): self
* @param bool $followLinks
* @return FileFinder
*/
public function followLinks($followLinks): self
public function followLinks($followLinks = true): self
{
$this->followLinks = (bool)$followLinks;

Expand All @@ -305,9 +315,7 @@ public function filter(\Closure $closure): self
*/
public function in($dirs): self
{
$this->dirs = array_merge($this->dirs, (array)$dirs);

return $this;
return $this->inDir($dirs);
}

/**
Expand All @@ -317,7 +325,9 @@ public function in($dirs): self
*/
public function inDir($dirs): self
{
$this->dirs = array_merge($this->dirs, (array)$dirs);
if ($dirs) {
$this->dirs = \array_merge($this->dirs, (array)$dirs);
}

return $this;
}
Expand Down

0 comments on commit 7f3d031

Please sign in to comment.