FromPairs   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 11 1
1
<?php
2
3
namespace Spatie\CollectionMacros\Macros;
4
5
use Illuminate\Support\Collection;
6
7
/**
8
 * Transform a collection into an associative array form collection item.
9
 *
10
 * @mixin \Illuminate\Support\Collection
11
 *
12
 * @return \Illuminate\Support\Collection
13
 */
14
class FromPairs
15
{
16
    public function __invoke()
17
    {
18
        return function (): Collection {
19
            return $this->reduce(function ($assoc, array $keyValuePair): Collection {
0 ignored issues
show
Bug introduced by Lucas Michot
The method reduce() does not seem to exist on object<Spatie\CollectionMacros\Macros\FromPairs>.

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...
20
                [$key, $value] = $keyValuePair;
0 ignored issues
show
Bug introduced by Rias
The variable $key does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by Rias
The variable $value does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
21
                $assoc[$key] = $value;
22
23
                return $assoc;
24
            }, new static);
25
        };
26
    }
27
}
28