Passed
Pull Request — master (#70)
by
unknown
03:59
created

Policies   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 42
ccs 10
cts 10
cp 1
rs 10
c 3
b 0
f 0
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A widgetShouldHaveDebugInfo() 0 3 2
A widgetShouldUseCache() 0 3 2
A widgetShouldBeMinified() 0 5 2
A widgetShouldBeExtracted() 0 4 1
1
<?php
2
3
namespace Imanghafoori\Widgets\Utils;
4
5
class Policies
6
{
7
    /**
8
     * Detects the widget Should Have Debug Info.
9
     *
10
     * @return bool
11
     */
12 20
    public function widgetShouldHaveDebugInfo(): bool
13
    {
14 20
        return config('widgetize.debug_info') && !app()->environment('production');
0 ignored issues
show
introduced by
The method environment() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

14
        return config('widgetize.debug_info') && !app()->/** @scrutinizer ignore-call */ environment('production');
Loading history...
15
    }
16
17
    /**
18
     * The caching is turned off when:
19
     * 1 - we are running tests
20
     * 2 - have disabled it in config file.
21
     *
22
     * @return bool
23
     */
24 24
    public function widgetShouldUseCache(): bool
25
    {
26 24
        return config('widgetize.enable_cache') && (!app()->environment('testing'));
27
    }
28
29
    /**
30
     * Widget Should Be Minified or Not.
31
     *
32
     * @param $widget
33
     *
34
     * @return bool
35
     */
36 20
    public function widgetShouldBeMinified($widget): bool
37
    {
38 20
        $conf = (config('widgetize.minify_html') || app()->environment('production'));
39
40 20
        return $widget->minifyOutput ?? $conf;
41
    }
42
43 20
    public function widgetShouldBeExtracted($widget): bool
0 ignored issues
show
Unused Code introduced by
The parameter $widget is not used and could be removed. ( Ignorable by Annotation )

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

43
    public function widgetShouldBeExtracted(/** @scrutinizer ignore-unused */ $widget): bool

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
    {
45 20
        $conf = config('widgetize.extract_data');
46 20
        return /* $widget->extract_data ?? */ $conf;
47
    }
48
}
49