Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Test Failed
Pull Request — main (#5688)
by Pedro
39:29 queued 16:36
created

BackpackManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 43
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A crudFromController() 0 14 1
A crud() 0 13 2
A hasCrudController() 0 3 1
A getControllerCrud() 0 3 1
1
<?php
2
3
namespace Backpack\CRUD;
4
5
use Backpack\CRUD\app\Http\Controllers\Contracts\CrudControllerContract;
6
use Backpack\CRUD\app\Library\CrudPanel\CrudPanel;
7
8
final class BackpackManager
9
{
10
    private array $cruds;
11
12
    public function crud(CrudControllerContract $controller): CrudPanel
13
    {
14
        $controllerClass = get_class($controller);
15
16
        if (isset($this->cruds[$controllerClass])) {
17
            return $this->cruds[$controllerClass];
18
        }
19
20
        $instance = new CrudPanel();
21
22
        $this->cruds[$controllerClass] = $instance;
23
24
        return $this->cruds[$controllerClass];
25
    }
26
27
    public function crudFromController(string $controller): CrudPanel
28
    {
29
        $controller = new $controller();
30
31
        $crud = $this->crud($controller);
32
33
        // TODO: it's hardcoded, but we should figure out a way to make it dynamic if needed.
34
        $crud->setOperation('list');
35
36
        $primaryControllerRequest = $this->cruds[array_key_first($this->cruds)]->getRequest();
37
38
        $controller->initializeCrud($primaryControllerRequest, 'list');
39
40
        return $this->cruds[get_class($controller)];
41
    }
42
43
    public function hasCrudController(string $controller): bool
44
    {
45
        return isset($this->cruds[$controller]);
46
    }
47
48
    public function getControllerCrud(string $controller): CrudPanel
49
    {
50
        return $this->cruds[$controller];
51
    }
52
}
53