Completed
Push — master ( 87a4b0...824833 )
by
unknown
14s
created

DMSCartAbstractController::getCart()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
class DMSCartAbstractController extends ContentController
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    /**
6
     * Ensure that links for this controller use the customised route.
7
     * Searches through the rules set up for the class and returns the first route.
8
     *
9
     * @param  string $action
0 ignored issues
show
Documentation introduced by
Should the type for parameter $action not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
10
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
11
     */
12
    public function Link($action = null)
13
    {
14
        if ($url = array_search(get_called_class(), (array)Config::inst()->get('Director', 'rules'))) {
15
            // Check for slashes and drop them
16
            if ($indexOf = stripos($url, '/')) {
17
                $url = substr($url, 0, $indexOf);
18
            }
19
            return $this->join_links($url, $action);
20
        }
21
    }
22
23
    /**
24
     * Retrieves a {@link DMSDocumentCart} instance
25
     *
26
     * @return DMSDocumentCart
27
     */
28
    public function getCart()
29
    {
30
        return DMSDocumentCart::singleton();
31
    }
32
33
    /**
34
     * Controls the `Continue browsing` link found in DMSCartNavigation.ss. Defaults all requests back to home.
35
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be false|string?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
36
     */
37
    public function getContinueBrowsingLink()
38
    {
39
        return Director::absoluteBaseURL();
40
    }
41
}
42