blockEditorInlineStyles()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Leonidas\Framework\Module\Abstracts;
4
5
use Leonidas\Contracts\Extension\ModuleInterface;
6
use Leonidas\Contracts\Ui\Asset\InlineScriptCollectionInterface;
7
use Leonidas\Contracts\Ui\Asset\InlineStyleCollectionInterface;
8
use Leonidas\Contracts\Ui\Asset\ScriptCollectionInterface;
9
use Leonidas\Contracts\Ui\Asset\ScriptLocalizationCollectionInterface;
10
use Leonidas\Contracts\Ui\Asset\StyleCollectionInterface;
11
use Leonidas\Framework\Module\Abstracts\Traits\ProvisionsAssetsTrait;
12
use Leonidas\Hooks\TargetsAdminEnqueueScriptsHook;
13
use Leonidas\Hooks\TargetsEnqueueBlockEditorAssetsHook;
14
use Leonidas\Hooks\TargetsLoginEnqueueScriptsHook;
15
use Leonidas\Hooks\TargetsScriptLoaderTagHook;
16
use Leonidas\Hooks\TargetsStyleLoaderTagHook;
17
use Leonidas\Hooks\TargetsWpEnqueueScriptsHook;
18
19
abstract class GlobalAssetProviderModule extends Module implements ModuleInterface
20
{
21
    use TargetsEnqueueBlockEditorAssetsHook;
22
    use TargetsAdminEnqueueScriptsHook;
23
    use TargetsLoginEnqueueScriptsHook;
24
    use TargetsWpEnqueueScriptsHook;
25
    use TargetsScriptLoaderTagHook;
26
    use TargetsStyleLoaderTagHook;
27
    use ProvisionsAssetsTrait;
28
29
    protected const CONTEXTS = [
30
        'admin_enqueue_scripts' => 'admin',
31
        'enqueue_block_editor_assets' => 'blockEditor',
32
        'login_enqueue_scripts' => 'login',
33
        'wp_enqueue_scripts' => 'public',
34
    ];
35
36
    public function hook(): void
37
    {
38
        $this->targetEnqueueBlockEditorAssetsHook();
39
        $this->targetAdminEnqueueScriptsHook();
40
        $this->targetLoginEnqueueScriptsHook();
41
        $this->targetWpEnqueueScriptsHook();
42
        // $this->targetScriptLoaderTagHook();
43
        // $this->targetStyleLoaderTagHook();
44
    }
45
46
    protected function doAdminEnqueueScriptsAction(string $hookSuffix): void
47
    {
48
        $this->provisionAssets($hookSuffix);
49
    }
50
51
    protected function doEnqueueBlockEditorAssetsAction(): void
52
    {
53
        $this->provisionAssets();
54
    }
55
56
    protected function doLoginEnqueueScriptsAction(): void
57
    {
58
        $this->provisionAssets();
59
    }
60
61
    protected function doWpEnqueueScriptsAction(): void
62
    {
63
        $this->provisionAssets();
64
    }
65
66
    protected function scripts(): ?ScriptCollectionInterface
67
    {
68
        return $this->getContextAssetsMethod('Scripts')();
69
    }
70
71
    protected function styles(): ?StyleCollectionInterface
72
    {
73
        return $this->getContextAssetsMethod('Styles')();
74
    }
75
76
    protected function inlineScripts(): ?InlineScriptCollectionInterface
77
    {
78
        return $this->getContextAssetsMethod('InlineScripts')();
79
    }
80
81
    protected function inlineStyles(): ?InlineStyleCollectionInterface
82
    {
83
        return $this->getContextAssetsMethod('InlineStyles')();
84
    }
85
86
    protected function scriptLocalizations(): ?ScriptLocalizationCollectionInterface
87
    {
88
        return $this->getContextAssetsMethod('ScriptLocalizations')();
89
    }
90
91
    protected function getContextAssetsMethod(string $type): array
92
    {
93
        return [$this, static::CONTEXTS[current_action()] . $type];
0 ignored issues
show
Bug introduced by
The function current_action was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

93
        return [$this, static::CONTEXTS[/** @scrutinizer ignore-call */ current_action()] . $type];
Loading history...
94
    }
95
96
    protected function adminScripts(): ?ScriptCollectionInterface
97
    {
98
        return null;
99
    }
100
101
    protected function adminStyles(): ?StyleCollectionInterface
102
    {
103
        return null;
104
    }
105
106
    protected function blockEditorScripts(): ?ScriptCollectionInterface
107
    {
108
        return null;
109
    }
110
111
    protected function blockEditorStyles(): ?StyleCollectionInterface
112
    {
113
        return null;
114
    }
115
116
    protected function loginScripts(): ?ScriptCollectionInterface
117
    {
118
        return null;
119
    }
120
121
    protected function loginStyles(): ?StyleCollectionInterface
122
    {
123
        return null;
124
    }
125
126
    protected function publicScripts(): ?ScriptCollectionInterface
127
    {
128
        return null;
129
    }
130
131
    protected function publicStyles(): ?StyleCollectionInterface
132
    {
133
        return null;
134
    }
135
136
    protected function adminInlineScripts(): ?InlineScriptCollectionInterface
137
    {
138
        return null;
139
    }
140
141
    protected function adminInlineStyles(): ?InlineStyleCollectionInterface
142
    {
143
        return null;
144
    }
145
146
    protected function blockEditorInlineScripts(): ?InlineScriptCollectionInterface
147
    {
148
        return null;
149
    }
150
151
    protected function blockEditorInlineStyles(): ?InlineStyleCollectionInterface
152
    {
153
        return null;
154
    }
155
156
    protected function loginInlineScripts(): ?InlineScriptCollectionInterface
157
    {
158
        return null;
159
    }
160
161
    protected function loginInlineStyles(): ?InlineStyleCollectionInterface
162
    {
163
        return null;
164
    }
165
166
    protected function publicInlineScripts(): ?InlineScriptCollectionInterface
167
    {
168
        return null;
169
    }
170
171
    protected function publicInlineStyles(): ?InlineStyleCollectionInterface
172
    {
173
        return null;
174
    }
175
176
    protected function adminScriptLocalizations(): ?ScriptLocalizationCollectionInterface
177
    {
178
        return null;
179
    }
180
181
    protected function blockEditorScriptLocalizations(): ?ScriptLocalizationCollectionInterface
182
    {
183
        return null;
184
    }
185
186
    protected function loginScriptLocalizations(): ?ScriptLocalizationCollectionInterface
187
    {
188
        return null;
189
    }
190
191
    protected function publicScriptLocalizations(): ?ScriptLocalizationCollectionInterface
192
    {
193
        return null;
194
    }
195
}
196