@@ 975-993 (lines=19) @@ | ||
972 | * @psalm-return static<TKey,T> |
|
973 | * @psalm-mutation-free |
|
974 | */ |
|
975 | public function appendToEachValue($prefix): self |
|
976 | { |
|
977 | // init |
|
978 | $result = []; |
|
979 | ||
980 | foreach ($this->getGenerator() as $key => $item) { |
|
981 | if ($item instanceof self) { |
|
982 | $result[$key] = $item->appendToEachValue($prefix); |
|
983 | } elseif (\is_array($item) === true) { |
|
984 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
985 | } elseif (\is_object($item) === true) { |
|
986 | $result[$key] = $item; |
|
987 | } else { |
|
988 | $result[$key] = $prefix . $item; |
|
989 | } |
|
990 | } |
|
991 | ||
992 | return self::create($result, $this->iteratorClass, false); |
|
993 | } |
|
994 | ||
995 | /** |
|
996 | * Sort an array in reverse order and maintain index association. |
|
@@ 4105-4132 (lines=28) @@ | ||
4102 | * @psalm-return static<TKey,T> |
|
4103 | * @psalm-mutation-free |
|
4104 | */ |
|
4105 | public function prependToEachValue($suffix): self |
|
4106 | { |
|
4107 | // init |
|
4108 | $result = []; |
|
4109 | ||
4110 | foreach ($this->getGenerator() as $key => $item) { |
|
4111 | if ($item instanceof self) { |
|
4112 | $result[$key] = $item->prependToEachValue($suffix); |
|
4113 | } elseif (\is_array($item) === true) { |
|
4114 | $result[$key] = self::create( |
|
4115 | $item, |
|
4116 | $this->iteratorClass, |
|
4117 | false |
|
4118 | )->prependToEachValue($suffix) |
|
4119 | ->toArray(); |
|
4120 | } elseif (\is_object($item) === true) { |
|
4121 | $result[$key] = $item; |
|
4122 | } else { |
|
4123 | $result[$key] = $item . $suffix; |
|
4124 | } |
|
4125 | } |
|
4126 | ||
4127 | return self::create( |
|
4128 | $result, |
|
4129 | $this->iteratorClass, |
|
4130 | false |
|
4131 | ); |
|
4132 | } |
|
4133 | ||
4134 | /** |
|
4135 | * Return the value of a given key and |