Passed
Push — main ( 04760e...0bf8e4 )
by Michael
01:04 queued 12s
created

run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
use MichaelRubel\EnhancedPipeline\Pipeline;
6
7
if (! function_exists('pipeline')) {
8
    /**
9
     * @param  mixed  $passable
10
     * @param  array|mixed  $pipes
11
     *
12
     * @return Pipeline
13
     */
14
    function pipeline($passable = null, $pipes = null): Pipeline
15
    {
16 2
        $pipeline = app(Pipeline::class);
17
18 2
        if (! is_null($passable)) {
19 1
            $pipeline->send($passable);
20
        }
21
22 2
        if (! is_null($pipes)) {
23 1
            $pipeline->through($pipes);
24
        }
25
26 2
        return $pipeline;
27
    }
28
}
29
30
if (! function_exists('run')) {
31
    /**
32
     * @param  string  $action
33
     * @param  mixed  $data
34
     * @return mixed
35
     */
36
    function run(string $action, mixed $data = true): mixed
37
    {
38 3
        return app(Pipeline::class)
39 3
            ->send($data)
40 3
            ->through([$action])
41 3
            ->thenReturn();
42
    }
43
}
44