Passed
Push — master ( 4a21d6...99257e )
by Yaroslav
02:31
created

HasDuskReporter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A makeWithDuskReporter() 0 3 1
A setDuskReporter() 0 5 1
A duskReporter() 0 3 1
A hasDuskReporter() 0 3 1
1
<?php
2
3
namespace LaravelDuskReporter;
4
5
use LaravelDuskReporter\Generation\ReportFileContract;
6
7
trait HasDuskReporter
8
{
9
    public ?ReportFileContract $duskReporter = null;
10
11
    /**
12
     * Get dusk reporter instance.
13
     *
14
     * @return ReportFileContract|null
15
     */
16
    public function duskReporter(): ?ReportFileContract
17
    {
18
        return $this->duskReporter;
19
    }
20
21
    /**
22
     * Check is object has dusk reporter.
23
     *
24
     * @return bool
25
     */
26
    public function hasDuskReporter(): bool
27
    {
28
        return !is_null($this->duskReporter());
29
    }
30
31
    /**
32
     * Set dusk reporter to object.
33
     *
34
     * @param ReportFileContract|null $reporter
35
     *
36
     * @return $this
37
     */
38
    public function setDuskReporter(?ReportFileContract $reporter): static
39
    {
40
        $this->duskReporter = $reporter;
41
42
        return $this;
43
    }
44
45
    /**
46
     * Initialise instance with dusk reporter.
47
     *
48
     * @param ReportFileContract $reporter
49
     * @param array $params
50
     *
51
     * @return static
52
     */
53
    public static function makeWithDuskReporter(ReportFileContract $reporter, array $params = []): static
54
    {
55
        return ( new static(...$params) )->setDuskReporter($reporter);
0 ignored issues
show
Unused Code introduced by
The call to LaravelDuskReporter\HasDuskReporter::__construct() has too many arguments starting with $params. ( Ignorable by Annotation )

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

55
        return ( /** @scrutinizer ignore-call */ new static(...$params) )->setDuskReporter($reporter);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
56
    }
57
}
58