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

Passed
Push — next ( d901ea...c80d63 )
by Cristian
17:46
created

Datatable   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 32
c 1
b 0
f 0
dl 0
loc 70
rs 10
wmc 8

4 Methods

Rating   Name   Duplication   Size   Complexity  
A generateTableId() 0 7 1
A getParentCrudEntry() 0 15 3
A __construct() 0 32 3
A render() 0 6 1
1
<?php
2
3
namespace Backpack\CRUD\app\View\Components;
4
5
use Backpack\CRUD\app\Library\CrudPanel\CrudPanel;
6
use Backpack\CRUD\app\Library\Support\DatatableCache;
7
use Backpack\CRUD\CrudManager;
8
use Illuminate\View\Component;
9
10
class Datatable extends Component
11
{
12
    protected string $tableId;
13
14
    public function __construct(
15
        private string $controller,
16
        private ?CrudPanel $crud = null,
17
        private bool $modifiesUrl = false,
18
        private ?\Closure $setup = null,
19
        private ?string $name = null,
20
    ) {
21
        // Set active controller for proper context
22
        CrudManager::setActiveController($controller);
0 ignored issues
show
Bug introduced by
The method setActiveController() does not exist on Backpack\CRUD\CrudManager. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

22
        CrudManager::/** @scrutinizer ignore-call */ 
23
                     setActiveController($controller);
Loading history...
23
24
        $this->crud ??= CrudManager::setupCrudPanel($controller, 'list');
0 ignored issues
show
Bug introduced by
The method setupCrudPanel() does not exist on Backpack\CRUD\CrudManager. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

24
        $this->crud ??= CrudManager::/** @scrutinizer ignore-call */ setupCrudPanel($controller, 'list');
Loading history...
25
26
        $this->tableId = $this->generateTableId();
27
28
        if ($this->setup) {
29
            // Apply the configuration using DatatableCache
30
            DatatableCache::applyAndStoreSetupClosure(
31
                $this->tableId,
32
                $this->controller,
33
                $this->setup,
34
                $this->name,
35
                $this->crud,
36
                $this->getParentCrudEntry()
37
            );
38
        }
39
40
        if (! $this->crud->has('list.datatablesUrl')) {
0 ignored issues
show
Bug introduced by
The method has() does not exist on null. ( Ignorable by Annotation )

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

40
        if (! $this->crud->/** @scrutinizer ignore-call */ has('list.datatablesUrl')) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
            $this->crud->set('list.datatablesUrl', $this->crud->getRoute());
42
        }
43
44
        // Reset the active controller
45
        CrudManager::unsetActiveController();
0 ignored issues
show
Bug introduced by
The method unsetActiveController() does not exist on Backpack\CRUD\CrudManager. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

45
        CrudManager::/** @scrutinizer ignore-call */ 
46
                     unsetActiveController();
Loading history...
46
    }
47
48
    private function getParentCrudEntry()
49
    {
50
        $cruds = CrudManager::getCrudPanels();
0 ignored issues
show
Bug introduced by
The method getCrudPanels() does not exist on Backpack\CRUD\CrudManager. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

50
        /** @scrutinizer ignore-call */ 
51
        $cruds = CrudManager::getCrudPanels();
Loading history...
51
        $parentCrud = reset($cruds);
52
53
        if ($parentCrud && $parentCrud->getCurrentEntry()) {
54
            CrudManager::storeInitializedOperation(
0 ignored issues
show
Bug introduced by
The method storeInitializedOperation() does not exist on Backpack\CRUD\CrudManager. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

54
            CrudManager::/** @scrutinizer ignore-call */ 
55
                         storeInitializedOperation(
Loading history...
55
                $parentCrud->controller,
56
                $parentCrud->getCurrentOperation()
57
            );
58
59
            return $parentCrud->getCurrentEntry();
60
        }
61
62
        return null;
63
    }
64
65
    private function generateTableId(): string
66
    {
67
        $controllerPart = str_replace('\\', '_', $this->controller);
68
        $namePart = $this->name ?? 'default';
69
        $uniqueId = md5($controllerPart.'_'.$namePart);
70
71
        return 'crudTable_'.$uniqueId;
72
    }
73
74
    public function render()
75
    {
76
        return view('crud::components.datatable.datatable', [
77
            'crud' => $this->crud,
78
            'modifiesUrl' => $this->modifiesUrl,
79
            'tableId' => $this->tableId,
80
        ]);
81
    }
82
}
83