Skip to content

Commit

Permalink
1.35.3
Browse files Browse the repository at this point in the history
* [+] Fixed joinName()
  • Loading branch information
KarelWintersky committed Jun 10, 2021
1 parent 8842815 commit 48f5822
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions sources/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,27 @@ public function joinName($data)
$data = $this->trimEach($data);

if ($this->isImmutable) {
return new self(array_merge($this->atoms, $data), $this->isImmutable, $this->isTrailingSlash);
return new self(array_merge($this->atoms, [ $data ]), $this->isImmutable, $this->isTrailingSlash);
}

$this->atoms = array_merge($this->atoms, $data);
$this->atoms = array_merge($this->atoms, [ $data ] );

return $this;
}

/**
* apply trim for each element of array
*
* @param $data
* @return array|string[]
* @param array|string $data
* @return string[]|string
*/
private function trimEach($data)
{
return array_map(static function ($item) { return trim($item, DIRECTORY_SEPARATOR); }, $data);
if (is_array($data)) {
return array_map(static function ($item) { return trim($item, DIRECTORY_SEPARATOR); }, $data);
}

return trim($data);
}


Expand Down

0 comments on commit 48f5822

Please sign in to comment.