Completed
Push — master ( 7feff4...723e59 )
by Iurii
01:48
created

Currency   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 52
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A hookModuleInstallBefore() 0 6 2
A hookRouteList() 0 10 1
A hookCron() 0 11 2
1
<?php
2
3
/**
4
 * @package Currency
5
 * @author Iurii Makukh <[email protected]>
6
 * @copyright Copyright (c) 2017, Iurii Makukh <[email protected]>
7
 * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License 3.0
8
 */
9
10
namespace gplcart\modules\currency;
11
12
use gplcart\core\Module;
13
14
/**
15
 * Main class for Currency module
16
 */
17
class Currency extends Module
18
{
19
20
    /**
21
     * Constructor
22
     */
23
    public function __construct()
24
    {
25
        parent::__construct();
26
    }
27
28
    /**
29
     * Implements hook "module.install.before"
30
     */
31
    public function hookModuleInstallBefore(&$result)
32
    {
33
        if (!function_exists('curl_init')) {
34
            $result = 'CURL library is not enabled';
35
        }
36
    }
37
38
    /**
39
     * Implements hook "route.list"
40
     * @param array $routes
41
     */
42
    public function hookRouteList(array &$routes)
43
    {
44
        // Module settings page
45
        $routes['admin/module/settings/currency'] = array(
46
            'access' => 'module_edit',
47
            'handlers' => array(
48
                'controller' => array('gplcart\\modules\\currency\\controllers\\Settings', 'editSettings')
49
            )
50
        );
51
    }
52
53
    /**
54
     * Implements hook "cron"
55
     */
56
    public function hookCron()
57
    {
58
        $settings = $this->config->module('currency');
59
60
        if (!empty($settings['status'])) {
61
            /* @var $model \gplcart\modules\currency\models\Currency */
62
            $currency = $this->getInstance('gplcart\\modules\\currency\\models\\Currency');
63
            $currency->setSettings($settings);
64
            $currency->update();
65
        }
66
    }
67
68
}
69