Completed
Push — develop ( 2d4f17...d5975b )
by Nate
05:25
created

LimitsController::actionIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 0
cts 16
cp 0
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/hubspot/license
6
 * @link       https://www.flipboxfactory.com/software/hubspot/
7
 */
8
9
namespace flipbox\craft\hubspot\cp\controllers\settings\view;
10
11
use flipbox\craft\hubspot\criteria\HubCriteria;
12
use flipbox\craft\hubspot\transformers\DynamicModelResponse;
13
use yii\web\Response;
14
15
/**
16
 * @author Flipbox Factory <[email protected]>
17
 * @since 1.0.0
18
 */
19
class LimitsController extends AbstractController
20
{
21
    /**
22
     * The template base path
23
     */
24
    const TEMPLATE_BASE = parent::TEMPLATE_BASE . '/limits';
25
26
    /**
27
     * The index view template path
28
     */
29
    const TEMPLATE_INDEX = self::TEMPLATE_BASE . '/index';
30
31
    /**
32
     * @return Response
33
     */
34
    public function actionIndex(): Response
35
    {
36
        $variables = [];
37
        $this->baseVariables($variables);
38
39
        $criteria = new HubCriteria();
40
41
        $variables['limits'] = call_user_func_array(
42
            new DynamicModelResponse(),
43
            [
44
                $criteria->dailyLimit()
45
            ]
46
        );
47
48
        return $this->renderTemplate(
49
            static::TEMPLATE_INDEX,
50
            $variables
51
        );
52
    }
53
54
    /*******************************************
55
     * BASE PATHS
56
     *******************************************/
57
58
    /**
59
     * @return string
60
     */
61
    protected function getBaseCpPath(): string
62
    {
63
        return parent::getBaseCpPath() . '/limits';
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    protected function getBaseActionPath(): string
70
    {
71
        return parent::getBaseActionPath() . '/limits';
72
    }
73
}
74