Install_Helper_Shop::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 0
dl 18
loc 18
rs 9.4285
c 0
b 0
f 0
1
<?php
2
class Install_Helper_Shop {
3
    
4
    private $kernel;
5
    private $db;
6
7
    public function __construct($kernel, $db) {
8
        $this->kernel = $kernel;
9
        $this->db = $db;
10
    }
11
    
12 View Code Duplication
    public function create() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
        
14
        require_once 'Intraface/modules/shop/Shop.php';
15
        $shop = new Intraface_modules_shop_Shop;
16
        $shop->intranet_id = $this->kernel->intranet->getId();
17
        $shop->name = 'test';
18
        $shop->description = 'test';
19
        $shop->identifier = 'test';
20
        $shop->show_online = 1;
21
        $shop->payment_link = '/demo/1/shop/1/basket/onlinepayment';
22
        $shop->confirmation = '';
23
        $shop->receipt = '<h3>Vi har modtaget din ordre</h3><p>Nu sker der følgende:</p><p>Vi sender, du pakker du</p>';
24
        
25
        $shop->save();
26
        
27
        
28
        return 1;
29
    }
30
    
31 View Code Duplication
    public function createWithDefaultCurrency() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
        
33
        require_once 'Intraface/modules/shop/Shop.php';
34
        $shop = new Intraface_modules_shop_Shop;
35
        $shop->intranet_id = $this->kernel->intranet->getId();
36
        $shop->name = 'test';
37
        $shop->description = 'test';
38
        $shop->identifier = 'test';
39
        $shop->default_currency_id = 1;
40
        $shop->show_online = 1;
41
        $shop->confirmation = '';
42
        $shop->receipt = '<h3>Vi har modtaget din ordre</h3><p>Nu sker der følgende:</p><p>Vi sender, du pakker du</p>';
43
        
44
        $shop->save();
45
        
46
        
47
        return 1;
48
    }
49
    
50
    public function createCategory($name = 'Category 1', $identifier = 'category1', $parent = 0) {
51
        
52
        $category = new Intraface_Category($this->kernel, $this->db, new Intraface_Category_Type('shop', 1));
53
        $category->setIdentifier($identifier);
54
        $category->setName($name);
55
        $category->setParentId($parent);
56
        $category->save();
57
        
58
        return $category;
59
        
60
    }
61
}
62
?>
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...