AjaxController   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A index() 0 10 1
1
<?php
2
3
/**
4
 * Class AjaxController
5
 * handle the ajax call to select the sorting and return a json response
6
 */
7
class AjaxController extends Controller
8
{
9
10
    private static $allowed_actions = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
11
        'index'
12
    );
13
14
    /**
15
     * @param SS_HTTPRequest $request
16
     * @return SS_HTTPResponse
17
     */
18
    public function index(SS_HTTPRequest $request)
19
    {
20
        $sortMethod = $request->postVar('type') . 'PopularAddons';
21
        $addons = HomeController::$sortMethod(5);
22
        $body = $this->renderWith('PopularAddons', array('PopularAddons' => $addons));
23
        $response = new SS_HTTPResponse();
24
        $response->addHeader('Content-Type', 'application/json');
25
        $response->setBody(Convert::array2json(array('success' => true, 'body' => $body->getValue())));
26
        return $response;
27
    }
28
}
29