AddSolutions   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 12 3
1
<?php
2
3
namespace Facade\Ignition\Middleware;
4
5
use Facade\FlareClient\Report;
6
use Facade\IgnitionContracts\SolutionProviderRepository;
7
8
class AddSolutions
9
{
10
    /** @var \Facade\IgnitionContracts\SolutionProviderRepository */
11
    protected $solutionProviderRepository;
12
13
    public function __construct(SolutionProviderRepository $solutionProviderRepository)
14
    {
15
        $this->solutionProviderRepository = $solutionProviderRepository;
16
    }
17
18
    public function handle(Report $report, $next)
19
    {
20
        if ($throwable = $report->getThrowable()) {
21
            $solutions = $this->solutionProviderRepository->getSolutionsForThrowable($throwable);
22
23
            foreach ($solutions as $solution) {
24
                $report->addSolution($solution);
0 ignored issues
show
Documentation introduced by
$solution is of type object<Facade\IgnitionCo...sSolutionsForThrowable>, but the function expects a object<Facade\IgnitionContracts\Solution>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
25
            }
26
        }
27
28
        return $next($report);
29
    }
30
}
31