Passed
Push — 1.0 ( 024343...5b8585 )
by Morven
10:07
created

ShoppingCart   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A AbsoluteLink() 0 3 1
A Link() 0 4 1
A RelativeLink() 0 5 1
1
<?php
2
3
namespace SilverCommerce\ShoppingCart\Model;
4
5
use SilverStripe\Control\Director;
6
use SilverStripe\Control\Controller;
7
use SilverStripe\Core\Injector\Injector;
8
use SilverCommerce\OrdersAdmin\Model\Estimate;
9
use SilverCommerce\ShoppingCart\Control\ShoppingCart as ShoppingCartController;
10
11
/**
12
 * Custom version of an estimate that is be mapped to the ShoppingCartController 
13
 */
14
class ShoppingCart extends Estimate
15
{
16
    private static $table_name = "ShoppingCart";
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
17
18
        /**
19
     * Get the link to this controller
20
     *
21
     * @param string $action The action you want to add to the link
22
     * @return string
23
     */
24
    public function Link($action = null)
25
    {
26
        $controller = Injector::inst()->create(ShoppingCartController::class);
27
        return $controller->Link($action);
28
    }
29
30
    /**
31
     * Get an absolute link to this controller
32
     *
33
     * @param string $action The action you want to add to the link
34
     * @return string
35
     */
36
    public function AbsoluteLink($action = null)
37
    {
38
        return Director::absoluteURL($this->Link($action));
39
    }
40
41
    /**
42
     * Get a relative (to the root url of the site) link to this
43
     * controller
44
     *
45
     * @param string $action The action you want to add to the link
46
     * @return string
47
     */
48
    public function RelativeLink($action = null)
49
    {
50
        return Controller::join_links(
51
            Director::baseURL(),
52
            $this->Link($action)
53
        );
54
    }
55
}
56