PipelineTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A it_can_be_composed_by_piping_multiple_pipelines() 0 11 1
A it_uses_stages_to_process_the_pipeline() 0 12 1
A it_passes_through_information_without_stages() 0 8 1
1
<?php
2
declare(strict_types=1);
3
4
namespace League\Pipeline;
5
6
use PHPUnit\Framework\Attributes\Test;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\Attributes\Test was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use PHPUnit\Framework\TestCase;
8
9
class PipelineTest extends TestCase
10
{
11
    #[Test]
12
    public function it_passes_through_information_without_stages(): void
13
    {
14
        $pipeline = new Pipeline();
15
16
        $result = $pipeline->process(10);
17
18
        self::assertEquals(10, $result);
19
    }
20
21
    #[Test]
22
    public function it_uses_stages_to_process_the_pipeline(): void
23
    {
24
        $pipeline = (new Pipeline())->pipe(
25
            function($p) { return $p * 10; },
26
        )->pipe(
27
            function($p) { return $p - 10; },
28
        );
29
30
        $result = $pipeline->process(10);
31
32
        self::assertEquals(90, $result);
33
    }
34
35
    #[Test]
36
    public function it_can_be_composed_by_piping_multiple_pipelines(): void
37
    {
38
        $pipeline1 = new Pipeline(null, function($p) { return $p * 10; });
39
        $pipeline2 = new Pipeline(null, function($p) { return $p - 10; });
40
41
        $pipeline = (new Pipeline())->pipe($pipeline1)->pipe($pipeline2);
42
43
        $result = $pipeline(10);
44
45
        self::assertEquals(90, $result);
46
    }
47
}