Tappable::tapIf()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
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