ExecuteSolutionRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 7 1
A getSolution() 0 9 1
A getRunnableSolution() 0 10 2
1
<?php
2
3
namespace Facade\Ignition\Http\Requests;
4
5
use Facade\IgnitionContracts\RunnableSolution;
6
use Facade\IgnitionContracts\Solution;
7
use Facade\IgnitionContracts\SolutionProviderRepository;
8
use Illuminate\Foundation\Http\FormRequest;
9
10
class ExecuteSolutionRequest extends FormRequest
11
{
12
    public function rules(): array
13
    {
14
        return [
15
            'solution' => 'required',
16
            'parameters' => 'array',
17
        ];
18
    }
19
20
    public function getSolution(): Solution
21
    {
22
        $solution = app(SolutionProviderRepository::class)
23
            ->getSolutionForClass($this->get('solution'));
24
25
        abort_if(is_null($solution), 404, 'Solution could not be found');
26
27
        return $solution;
28
    }
29
30
    public function getRunnableSolution(): RunnableSolution
31
    {
32
        $solution = $this->getSolution();
33
34
        if (! $solution instanceof RunnableSolution) {
35
            abort(404, 'Runnable solution could not be found');
36
        }
37
38
        return $solution;
39
    }
40
}
41