Skip to content

Commit

Permalink
Merge pull request #15 from TypiCMS/analysis-qxeoyA
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
sdebacker authored Apr 6, 2017
2 parents 7d24fc0 + 61dc357 commit 1cc48e9
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/NestableCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ public function nest()
* Recursive function that flatten a nested Collection
* with characters (default is four spaces).
*
* @param string $column
* @param string $column
* @param BaseCollection|null $collection
* @param int $level
* @param array &$flattened
* @param string|null $indentChars
* @param string|boolen|null $parent_string
* @param int $level
* @param array &$flattened
* @param string|null $indentChars
* @param string|boolen|null $parent_string
*
* @return array
*/
Expand All @@ -94,24 +94,23 @@ public function listsFlattened($column = 'title', BaseCollection $collection = n
$collection = $collection ?: $this;
$indentChars = $indentChars ?: $this->indentChars;
foreach ($collection as $item) {
if($parent_string) {
$item_string = ($parent_string === true)? $item->$column: $parent_string.$indentChars.$item->$column;
}
else {
if ($parent_string) {
$item_string = ($parent_string === true) ? $item->$column : $parent_string.$indentChars.$item->$column;
} else {
$item_string = str_repeat($indentChars, $level).$item->$column;
}

$flattened[$item->id] = $item_string;
if ($item->items) {
$this->listsFlattened($column, $item->items, $level + 1, $flattened, $indentChars, ($parent_string)? $item_string: null);
$this->listsFlattened($column, $item->items, $level + 1, $flattened, $indentChars, ($parent_string) ? $item_string : null);
}
}

return $flattened;
}

/**
* Returns a fully qualified version of listsFlattened
* Returns a fully qualified version of listsFlattened.
*
* @param BaseCollection|null $collection
* @param string $column
Expand All @@ -127,13 +126,16 @@ public function listsFlattenedQualified($column = 'title', BaseCollection $colle
}

/**
* Change the default indent characters when flattening lists
* Change the default indent characters when flattening lists.
*
* @param string $indentChars
*
* @return $this
*/
public function setIndent(string $indentChars) {
public function setIndent(string $indentChars)
{
$this->indentChars = $indentChars;

return $this;
}

Expand Down

0 comments on commit 1cc48e9

Please sign in to comment.