GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( d56ba6...25ad0d )
by Dušan
02:43
created

CustomPassthroughFunctionTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
dl 0
loc 64
rs 10
wmc 1
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A testIt() 0 56 1
1
<?php
2
3
namespace DusanKasan\Knapsack\Tests\Scenarios;
4
5
use DusanKasan\Knapsack\Collection;
6
use PHPUnit_Framework_TestCase;
7
8
class CustomPassthroughFunctionTest extends PHPUnit_Framework_TestCase
9
{
10
    /**
11
     * Example of implementing a transpose function and how to apply it over a collection.
12
     *
13
     * For more on how this can be useful: http://adamwathan.me/2016/04/06/cleaning-up-form-input-with-transpose/
14
     */
15
    public function testIt()
16
    {
17
        $formData = [
18
            'names' => [
19
                'Jane',
20
                'Bob',
21
                'Mary',
22
            ],
23
            'emails' => [
24
                '[email protected]',
25
                '[email protected]',
26
                '[email protected]',
27
            ],
28
            'occupations' => [
29
                'Doctor',
30
                'Plumber',
31
                'Dentist',
32
            ],
33
        ];
34
35
        //Must take and return a Collection
36
        $transpose = function (Collection $collections) {
37
            $transposed = array_map(
38
                function (...$items) {
39
                    return $items;
40
                },
41
                ...$collections->values()->toArray()
42
            );
43
44
            return Collection::from($transposed);
45
        };
46
47
        $result = Collection::from($formData)
48
            ->transform($transpose)
49
            ->toArray();
50
51
        $expected = [
52
            [
53
                'Jane',
54
                '[email protected]',
55
                'Doctor'
56
            ],
57
            [
58
                'Bob',
59
                '[email protected]',
60
                'Plumber'
61
            ],
62
            [
63
                'Mary',
64
                '[email protected]',
65
                'Dentist'
66
            ]
67
        ];
68
69
        $this->assertEquals($expected, $result);
70
    }
71
}
72