Main   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A hookRouteList() 0 9 1
A getProvider() 0 4 1
A getProviders() 0 4 1
A authorize() 0 4 1
A getModel() 0 6 1
A getJwtHelper() 0 6 1
1
<?php
2
3
/**
4
 * @package Oauth
5
 * @author Iurii Makukh <[email protected]>
6
 * @copyright Copyright (c) 2018, Iurii Makukh <[email protected]>
7
 * @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3.0-or-later
8
 */
9
10
namespace gplcart\modules\oauth;
11
12
use gplcart\core\Container;
13
14
/**
15
 * Main class for Oauth module
16
 */
17
class Main
18
{
19
20
    /**
21
     * Implements hook "route.list"
22
     * @param array $routes
23
     */
24
    public function hookRouteList(array &$routes)
25
    {
26
        $routes['oauth'] = array(
27
            'internal' => true,
28
            'handlers' => array(
29
                'controller' => array('gplcart\\modules\\oauth\\controllers\\Oauth', 'callbackOauth')
30
            )
31
        );
32
    }
33
34
    /**
35
     * Returns a provider
36
     * @param string $id
37
     * @return array
38
     */
39
    public function getProvider($id)
40
    {
41
        return $this->getModel()->getProvider($id);
42
    }
43
44
    /**
45
     * Returns an array of providers
46
     * @param array $options
47
     * @return array
48
     */
49
    public function getProviders(array $options = array())
50
    {
51
        return $this->getModel()->getProviders($options);
52
    }
53
54
    /**
55
     * Does main authorization process
56
     * @param array $provider
57
     * @param array $options
58
     * @return mixed
59
     */
60
    public function authorize(array $provider, array $options)
61
    {
62
        return $this->getModel()->authorize($provider, $options);
63
    }
64
65
    /**
66
     * Returns the Oauth model instance
67
     * @return \gplcart\modules\oauth\models\Oauth
68
     */
69
    public function getModel()
70
    {
71
        /** @var \gplcart\modules\oauth\models\Oauth $instance */
72
        $instance = Container::get('gplcart\\modules\\oauth\\models\\Oauth');
73
        return $instance;
74
    }
75
76
    /**
77
     * Returns JWT helper class instance
78
     * @return \gplcart\modules\oauth\helpers\Jwt
79
     */
80
    public function getJwtHelper()
81
    {
82
        /** @var \gplcart\modules\oauth\helpers\Jwt $instance */
83
        $instance = Container::get('gplcart\\modules\\oauth\\helpers\\Jwt');
84
        return $instance;
85
    }
86
}
87