ImageEditors   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A defineWpImageEditorsPriority() 0 3 1
A filterWpImageEditors() 0 5 2
A editors() 0 3 1
A shouldReplaceEditors() 0 3 1
A hook() 0 3 1
1
<?php
2
3
namespace Leonidas\Framework\Site\Module;
4
5
use Leonidas\Framework\Module\Abstracts\Module;
6
use Leonidas\Hooks\TargetsWpImageEditorsHook;
7
use WP_Image_Editor;
0 ignored issues
show
Bug introduced by
The type WP_Image_Editor was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
class ImageEditors extends Module
10
{
11
    use TargetsWpImageEditorsHook;
12
13
    public function hook(): void
14
    {
15
        $this->targetWpImageEditorsHook();
16
    }
17
18
    protected function defineWpImageEditorsPriority(): int
19
    {
20
        return 10;
21
    }
22
23
    protected function filterWpImageEditors(array $imageEditors): array
24
    {
25
        return $this->shouldReplaceEditors()
26
            ? $this->editors()
27
            : array_merge($this->editors(), $imageEditors);
28
    }
29
30
    protected function shouldReplaceEditors(): bool
31
    {
32
        return $this->getConfig('modules.image_editors.replace', true);
33
    }
34
35
    /**
36
     * @return WP_Image_Editor[]
37
     */
38
    protected function editors(): array
39
    {
40
        return $this->getConfig('images.editors', []);
41
    }
42
}
43