Completed
Pull Request — master (#659)
by
unknown
02:41
created

ForEachCest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B setIterableWithDeferTaskConfiguration() 0 37 1
1
<?php
2
3
use Robo\Collection\CollectionBuilder;
4
5
class ForEachCest {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
7
    public function setIterableWithDeferTaskConfiguration(CliGuy $I)
8
    {
9
        $I->wantTo('set iterable with deferTaskConfiguration()');
10
11
        $expected = [
12
            'a = b',
13
            'c = d',
14
            'e = f',
15
        ];
16
        $actual = [];
17
        $I
18
            ->collectionBuilder()
19
            ->addCode(function (\Robo\State\Data $data) {
20
                $data['items'] = [
21
                    'a' => 'b',
22
                    'c' => 'd',
23
                    'e' => 'f',
24
                ];
25
26
                return 0;
27
            })
28
            ->addTask(
29
                $I
30
                    ->taskForEach()
31
                    ->deferTaskConfiguration('setIterable', 'items')
32
                    ->withBuilder(function (CollectionBuilder $builder, $key, $value) use (&$actual) {
33
                        $builder->addCode(function () use ($key, $value, &$actual) {
34
                            $actual[] = "$key = $value";
35
36
                            return 0;
37
                        });
38
                    })
39
            )
40
            ->run();
41
42
        $I->assertEquals($expected, $actual);
43
    }
44
}
45