@@ 1101-1119 (lines=19) @@ | ||
1098 | * @phpstan-return static<TKey,T> |
|
1099 | * @psalm-mutation-free |
|
1100 | */ |
|
1101 | public function appendToEachValue($prefix): self |
|
1102 | { |
|
1103 | // init |
|
1104 | $result = []; |
|
1105 | ||
1106 | foreach ($this->getGenerator() as $key => $item) { |
|
1107 | if ($item instanceof self) { |
|
1108 | $result[$key] = $item->appendToEachValue($prefix); |
|
1109 | } elseif (\is_array($item)) { |
|
1110 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
1111 | } elseif (\is_object($item) === true) { |
|
1112 | $result[$key] = $item; |
|
1113 | } else { |
|
1114 | $result[$key] = $prefix . $item; |
|
1115 | } |
|
1116 | } |
|
1117 | ||
1118 | return self::create($result, $this->iteratorClass, false); |
|
1119 | } |
|
1120 | ||
1121 | /** |
|
1122 | * Sort an array in reverse order and maintain index association. |
|
@@ 5005-5032 (lines=28) @@ | ||
5002 | * @phpstan-return static<TKey,T> |
|
5003 | * @psalm-mutation-free |
|
5004 | */ |
|
5005 | public function prependToEachValue($suffix): self |
|
5006 | { |
|
5007 | // init |
|
5008 | $result = []; |
|
5009 | ||
5010 | foreach ($this->getGenerator() as $key => $item) { |
|
5011 | if ($item instanceof self) { |
|
5012 | $result[$key] = $item->prependToEachValue($suffix); |
|
5013 | } elseif (\is_array($item)) { |
|
5014 | $result[$key] = self::create( |
|
5015 | $item, |
|
5016 | $this->iteratorClass, |
|
5017 | false |
|
5018 | )->prependToEachValue($suffix) |
|
5019 | ->toArray(); |
|
5020 | } elseif (\is_object($item) === true) { |
|
5021 | $result[$key] = $item; |
|
5022 | } else { |
|
5023 | $result[$key] = $item . $suffix; |
|
5024 | } |
|
5025 | } |
|
5026 | ||
5027 | return self::create( |
|
5028 | $result, |
|
5029 | $this->iteratorClass, |
|
5030 | false |
|
5031 | ); |
|
5032 | } |
|
5033 | ||
5034 | /** |
|
5035 | * Return the value of a given key and |