Test Failed
Push — master ( f2a606...7148c0 )
by Terzi
03:41
created

AcceptsCustomFormat::hasCustomFormat()   A

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 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 0
cts 1
cp 0
crap 2
1
<?php
2
3
namespace Terranet\Administrator\Field\Traits;
4
5
use Closure;
6
7
trait AcceptsCustomFormat
8
{
9
    /** @var null|Closure */
10
    protected $format;
11
12
    /**
13
     * @return bool
14
     */
15
    public function hasCustomFormat(): bool
16
    {
17
        return null !== $this->format;
18
    }
19
20
    /**
21
     * @param Closure $format
22
     *
23
     * @return self
24
     */
25
    public function renderAs(Closure $format): self
26
    {
27
        $this->format = $format;
28
29
        return $this;
30
    }
31
32
    /**
33
     * @param $args
34
     *
35
     * @return mixed
36
     */
37
    protected function callFormatter(...$args)
38
    {
39
        return $this->format->call($this, ...$args);
0 ignored issues
show
Bug introduced by
The method call() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        return $this->format->/** @scrutinizer ignore-call */ call($this, ...$args);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
    }
41
}
42