Tappable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 26
ccs 0
cts 4
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A tapIf() 0 3 1
A tapUnless() 0 3 1
1
<?php
2
3
namespace Ianrizky\Illuminate\Support\Traits;
4
5
use Illuminate\Support\Traits\Tappable as BaseTappable;
6
7
trait Tappable
8
{
9
    use BaseTappable;
10
11
    /**
12
     * Call the given Closure with this instance then return the instance if the given condition is true.
13
     *
14
     * @param  mixed  $condition
15
     * @param  callable|null  $callback
16
     * @return $this|\Illuminate\Support\HigherOrderTapProxy
17
     */
18
    public function tapIf($condition, callable $callback = null)
19
    {
20
        return tap_if($condition, $this, $callback);
21
    }
22
23
    /**
24
     * Call the given Closure with this instance then return the instance unless the given condition is true.
25
     *
26
     * @param  mixed  $condition
27
     * @param  callable|null  $callback
28
     * @return $this|\Illuminate\Support\HigherOrderTapProxy
29
     */
30
    public function tapUnless($condition, callable $callback = null)
31
    {
32
        return tap_unless($condition, $this, $callback);
33
    }
34
}
35