StaticSiteTransformResult::__construct()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 21
rs 9.6111
cc 5
nc 5
nop 2
1
<?php
2
3
namespace PhpTek\Exodus\Transform;
4
5
use SilverStripe\Assets\File;
6
use SilverStripe\CMS\Model\SiteTree;
7
use SilverStripe\Core\Config\Configurable;
8
use SilverStripe\Core\Injector\Injectable;
9
10
/**
11
 * Encapsulates the result of a transformation.
12
 * It subclasses {@link TransformResult} to allow dealing-to File objects also
13
 *
14
 * @package phptek/silverstripe-exodus
15
 * @author Russell Michell <[email protected]>
16
 * @todo Logic should really exist in external-content module itself.
17
 */
18
class StaticSiteTransformResult extends \TransformResult
19
{
20
    use Injectable;
21
    use Configurable;
22
23
    /**
24
     *
25
     * @var File
26
     */
27
    public $file;
28
29
    /**
30
     *
31
     * @var SiteTree
32
     */
33
    public $page;
34
35
    /**
36
     *
37
     * @var array
38
     */
39
    public $children;
40
41
    /**
42
     *
43
     * @param SiteTree $object
44
     * @param SS_List $children
0 ignored issues
show
Bug introduced by
The type PhpTek\Exodus\Transform\SS_List 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...
45
     * @return void
46
     */
47
    public function __construct($object, $children)
48
    {
49
        parent::__construct($object, $children);
50
51
        $instanceOfSiteTree = ($object instanceof SiteTree);
52
        $instanceOfFile = ($object instanceof File);
53
54
        if (!$instanceOfSiteTree && !$instanceOfFile) {
0 ignored issues
show
introduced by
The condition $instanceOfSiteTree is always true.
Loading history...
55
            user_error("Incorrect type passed to class constructor.");
56
            exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
57
        }
58
59
        if ($instanceOfSiteTree) {
60
            $this->page = $object;
61
        }
62
63
        if ($instanceOfFile) {
64
            $this->file = $object;
0 ignored issues
show
Documentation Bug introduced by
It seems like $object of type SilverStripe\CMS\Model\SiteTree is incompatible with the declared type SilverStripe\Assets\File of property $file.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
65
        }
66
67
        $this->children = $children;
0 ignored issues
show
Documentation Bug introduced by
It seems like $children of type PhpTek\Exodus\Transform\SS_List is incompatible with the declared type array of property $children.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
68
    }
69
}
70