Passed
Pull Request — master (#774)
by
unknown
05:46
created

FluentExtension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A assignTopPage() 0 5 1
A clearTopPage() 0 5 1
1
<?php
2
3
namespace DNADesign\Elemental\TopPage;
4
5
use DNADesign\Elemental\Models\BaseElement;
6
use DNADesign\Elemental\Models\ElementalArea;
7
use Page;
0 ignored issues
show
Bug introduced by
The type Page 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
use TractorCow\Fluent\State\FluentState;
0 ignored issues
show
Bug introduced by
The type TractorCow\Fluent\State\FluentState 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...
9
10
/**
11
 * Class FluentExtension
12
 *
13
 * Use this extension in case you use the Fluent module (https://github.com/tractorcow-farm/silverstripe-fluent)
14
 * for page localisation
15
 * this will keep track of the locale the nested data object is stored in
16
 *
17
 * @property string $TopPageLocale
18
 * @property BaseElement|ElementalArea|$this $owner
19
 * @package DNADesign\Elemental\TopPage
20
 */
21
class FluentExtension extends DataExtension
22
{
23
    /**
24
     * @var array
25
     */
26
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
27
        'TopPageLocale' => 'Varchar',
28
    ];
29
30
    protected function assignTopPage(Page $page): void
31
    {
32
        parent::assignTopPage($page);
33
34
        $this->owner->TopPageLocale = FluentState::singleton()->getLocale();
0 ignored issues
show
Bug Best Practice introduced by
The property TopPageLocale does not exist on DNADesign\Elemental\Models\ElementalArea. Since you implemented __set, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property TopPageLocale does not exist on DNADesign\Elemental\Models\BaseElement. Since you implemented __set, consider adding a @property annotation.
Loading history...
35
    }
36
37
    protected function clearTopPage(): void
38
    {
39
        parent::clearTopPage();
40
41
        $this->owner->TopPageLocale = null;
0 ignored issues
show
Bug Best Practice introduced by
The property TopPageLocale does not exist on DNADesign\Elemental\Models\BaseElement. Since you implemented __set, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property TopPageLocale does not exist on DNADesign\Elemental\Models\ElementalArea. Since you implemented __set, consider adding a @property annotation.
Loading history...
42
    }
43
}
44