ReportSolution   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fromSolution() 0 4 1
A toArray() 0 13 2
1
<?php
2
3
namespace Facade\FlareClient\Solutions;
4
5
use Facade\IgnitionContracts\RunnableSolution;
6
use Facade\IgnitionContracts\Solution as SolutionContract;
7
8
class ReportSolution
9
{
10
    /** @var SolutionContract */
11
    protected $solution;
12
13
    public function __construct(SolutionContract $solution)
14
    {
15
        $this->solution = $solution;
16
    }
17
18
    public static function fromSolution(SolutionContract $solution)
19
    {
20
        return new static($solution);
21
    }
22
23
    public function toArray(): array
24
    {
25
        $isRunnable = ($this->solution instanceof RunnableSolution);
26
27
        return [
28
            'class' => get_class($this->solution),
29
            'title' => $this->solution->getSolutionTitle(),
30
            'description' => $this->solution->getSolutionDescription(),
31
            'links' => $this->solution->getDocumentationLinks(),
32
            'action_description' => $isRunnable ? $this->solution->getSolutionActionDescription() : null,
33
            'is_runnable' => $isRunnable,
34
        ];
35
    }
36
}
37