Completed
Push — master ( 0b0948...d09d59 )
by Nate
11:01 queued 09:52
created

HubSpot::getVisitor()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 0
cts 21
cp 0
rs 9.584
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
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\web\twig\variables;
10
11
use Craft;
12
use flipbox\craft\hubspot\HubSpot as HubSpotPlugin;
13
use flipbox\craft\hubspot\models\Settings;
14
use flipbox\craft\hubspot\services\Cache;
15
use flipbox\craft\hubspot\services\Connections;
16
use yii\di\ServiceLocator;
17
use yii\helpers\Json;
18
19
/**
20
 * @author Flipbox Factory <[email protected]>
21
 * @since 1.0.0
22
 */
23
class HubSpot extends ServiceLocator
24
{
25
    use VisitorTrait;
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function init()
31
    {
32
        parent::init();
33
34
        $this->setComponents([
35
            'cache' => HubSpotPlugin::getInstance()->getCache(),
36
            'connections' => HubSpotPlugin::getInstance()->getConnections(),
37
            'criteria' => Criteria::class
38
        ]);
39
    }
40
41
    /**
42
     * Sub-Variables that are accessed 'craft.hubspot.settings'
43
     *
44
     * @return Settings
45
     */
46
    public function getSettings()
47
    {
48
        return HubSpotPlugin::getInstance()->getSettings();
49
    }
50
51
    /**
52
     * @noinspection PhpDocMissingThrowsInspection
53
     * @return Cache
54
     */
55
    public function getCache(): Cache
56
    {
57
        /** @noinspection PhpUnhandledExceptionInspection */
58
        /** @noinspection PhpIncompatibleReturnTypeInspection */
59
        return $this->get('cache');
60
    }
61
62
    /**
63
     * @noinspection PhpDocMissingThrowsInspection
64
     * @return Connections
65
     */
66
    public function getConnections(): Connections
67
    {
68
        /** @noinspection PhpUnhandledExceptionInspection */
69
        /** @noinspection PhpIncompatibleReturnTypeInspection */
70
        return $this->get('connections');
71
    }
72
}
73