Install_Helper_CMS::createSiteWithTemplate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 0
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
class Install_Helper_CMS
3
{
4
    private $kernel;
5
    private $db;
6
7
    public function __construct($kernel, $db)
8
    {
9
        $this->kernel = $kernel;
10
        $this->db = $db;
11
    }
12
13
    public function createSite()
14
    {
15
        require_once 'Intraface/modules/cms/Site.php';
16
        $site = new CMS_Site($this->kernel);
17
        $site_id = $site->save(array('name' => 'Test', 'url' => 'http://localhost/'));
0 ignored issues
show
Unused Code introduced by
$site_id is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
18
19
20
    }
21
22
    public function createSiteWithTemplate() {
23
        require_once 'Intraface/modules/cms/Site.php';
24
        $site = new CMS_Site($this->kernel);
25
        $site_id = $site->save(array('name' => 'Test', 'url' => 'http://localhost/'));
0 ignored issues
show
Unused Code introduced by
$site_id is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
26
27
        require_once 'Intraface/modules/cms/Template.php';
28
        $template = new CMS_Template($site);
29
        $template_id = $template->save(array('name' => 'Test', 'identifier' => 'test', 'for_page_type' => array(1, 2, 4)));
0 ignored issues
show
Unused Code introduced by
$template_id is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
30
31
        require_once 'Intraface/modules/cms/TemplateSection.php';
32
        require_once 'Intraface/modules/cms/templatesection/Mixed.php';
33
        $section = new Intraface_modules_cms_templatesection_Mixed($template);
34
        $section_id = $section->save(array('name' => 'Test', 'identifier' => 'test', 'allowed_element' => array(1, 2, 3, 4, 5, 6, 7, 8, 9)));
0 ignored issues
show
Unused Code introduced by
$section_id is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
35
36
    }
37
38
    public function createPageWithMixedSection() {
39
40
        require_once 'Intraface/modules/cms/Site.php';
41
        $site = new CMS_Site($this->kernel);
42
        $site_id = $site->save(array('name' => 'Test', 'url' => 'http://localhost/'));
43
        if (!$site_id) {
44
            throw new Exception('Error: '.implode(', ', $site->error->getMessage()));
45
        }
46
47
        require_once 'Intraface/modules/cms/Template.php';
48
        $template = new CMS_Template($site);
49
        $template_id = $template->save(array('name' => 'Test', 'identifier' => 'test', 'for_page_type' => array(1, 2, 4)));
50
51
        require_once 'Intraface/modules/cms/TemplateSection.php';
52
        $section = new Intraface_modules_cms_templatesection_Mixed($template);
53
        $section_id = $section->save(array('name' => 'Content', 'identifier' => 'content', 'allowed_element' => array(1, 2, 3, 4, 5, 6, 7, 8, 9)));
0 ignored issues
show
Unused Code introduced by
$section_id is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
54
55
        require_once 'Intraface/modules/cms/Page.php';
56
        $page = new CMS_Page($site);
57
        $template_id = $page->save(array('title' => 'Test', 'allow_comment' => 0, 'hidden' => 0, 'page_type' => 'page', 'template_id' => $template_id, 'identifier' => 'test'));
0 ignored issues
show
Unused Code introduced by
$template_id is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
58
59
    }
60
}
61
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
62