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
Pull Request — main (#5715)
by Cristian
11:33
created

LifecycleHooks   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hookInto() 0 5 3
A has() 0 3 1
A trigger() 0 8 6
1
<?php
2
3
namespace Backpack\CRUD\app\Library\CrudPanel\Hooks;
4
5
final class LifecycleHooks
6
{
7
    public array $hooks = [];
8
9
    public function hookInto(string|array $hooks, callable $callback): void
10
    {
11
        $hooks = is_array($hooks) ? $hooks : [$hooks];
0 ignored issues
show
introduced by
The condition is_array($hooks) is always true.
Loading history...
12
        foreach ($hooks as $hook) {
13
            $this->hooks[$hook][] = $callback;
14
        }
15
    }
16
17
    public function trigger(string|array $hooks, array $parameters = []): void
18
    {
19
        $hooks = is_array($hooks) ? $hooks : [$hooks];
0 ignored issues
show
introduced by
The condition is_array($hooks) is always true.
Loading history...
20
        foreach ($hooks as $hook) {
21
            if (isset($this->hooks[$hook])) {
22
                foreach ($this->hooks[$hook] as $callback) {
23
                    if ($callback instanceof \Closure) {
24
                        $callback(...$parameters);
25
                    }
26
                }
27
            }
28
        }
29
    }
30
31
    public function has(string $hook): bool
32
    {
33
        return isset($this->hooks[$hook]);
34
    }
35
}
36