Completed
Push — master ( 0ecc0a...a7a477 )
by Thijs van den
01:15
created

ReplaceInKeys::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Bitsnbolts\LaravelCollectionMacros\Macros;
4
5
use Illuminate\Support\Collection;
6
7
/**
8
 * Do a str_replace on all the keys of the collection.
9
 *
10
 * @param string $search
11
 * @param string $replace
12
 *
13
 * @mixin \Illuminate\Support\Collection
14
 *
15
 * @return mixed
16
 */
17
class ReplaceInKeys
18
{
19
    public function __invoke()
20
    {
21
        /**
22
         * @param $search
23
         * @param $replace
24
         * @return Collection
25
         */
26
        return function ($search, $replace) {
27
            return $this->mapWithKeys(function ($value, $key) use ($search, $replace) {
0 ignored issues
show
Bug introduced by
The method mapWithKeys() does not seem to exist on object<Bitsnbolts\Larave...s\Macros\ReplaceInKeys>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
                return [str_replace($search, $replace, $key) =>  $value];
29
            });
30
        };
31
    }
32
}
33