HubSpot::setConnection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipbox/hubspot/blob/master/LICENSE.md
6
 * @link       https://github.com/flipbox/hubspot
7
 */
8
9
namespace Flipbox\HubSpot;
10
11
use Flipbox\HubSpot\Connections\ConnectionInterface;
12
use Flipbox\HubSpot\Connections\IntegrationConnectionInterface;
13
use Flipbox\Skeleton\Logger\StaticLoggerTrait;
14
use Psr\Log\LoggerInterface;
15
use Psr\SimpleCache\CacheInterface;
16
17
/**
18
 * @author Flipbox Factory <[email protected]>
19
 * @since 2.0.0
20
 */
21
class HubSpot
22
{
23
    use StaticLoggerTrait;
24
25
    /**
26
     * @var CacheInterface
27
     */
28
    private static $cache;
29
30
    /**
31
     * @var ConnectionInterface
32
     */
33
    private static $connection;
34
35
    /**
36
     * @var IntegrationConnectionInterface
37
     */
38
    private static $integrationConnection;
39
40
    /**
41
     * @var LoggerInterface
42
     */
43
    private static $logger;
44
45
46
    /*******************************************
47
     * LOGGER
48
     *******************************************/
49
50
    /**
51
     * Get a logger
52
     *
53
     * @return LoggerInterface|null
54
     */
55
    public static function getLogger()
56
    {
57
        return self::$logger;
58
    }
59
60
    /**
61
     * Set a logger
62
     *
63
     * @param LoggerInterface|null $logger
64
     */
65
    public static function setLogger(LoggerInterface $logger = null)
66
    {
67
        self::$logger = $logger;
68
    }
69
70
    /**
71
     * Logs with an arbitrary level.
72
     *
73
     * @param mixed $level
74
     * @param string $message
75
     * @param array $context
76
     *
77
     */
78
    public static function log($level, $message, array $context = [])
79
    {
80
        if (null !== ($logger = static::getLogger())) {
81
            $logger->log($level, $message, $context);
82
        }
83
    }
84
85
86
    /*******************************************
87
     * CACHE
88
     *******************************************/
89
90
    /**
91
     * Get the cache
92
     *
93
     * @return CacheInterface
94
     */
95
    public static function getCache(): CacheInterface
96
    {
97
        return self::$cache;
98
    }
99
100
    /**
101
     * Set the cache
102
     *
103
     * @param CacheInterface $cache
104
     */
105
    public static function setCache(CacheInterface $cache)
106
    {
107
        self::$cache = $cache;
108
    }
109
110
111
    /*******************************************
112
     * CONNECTION
113
     *******************************************/
114
115
    /**
116
     * Get the connection
117
     *
118
     * @return ConnectionInterface
119
     */
120
    public static function getConnection(): ConnectionInterface
121
    {
122
        return self::$connection;
123
    }
124
125
    /**
126
     * Set the connection
127
     *
128
     * @param ConnectionInterface $connection
129
     */
130
    public static function setConnection(ConnectionInterface $connection)
131
    {
132
        self::$connection = $connection;
133
    }
134
135
136
    /*******************************************
137
     * INTEGRATION CONNECTION
138
     *******************************************/
139
140
    /**
141
     * Get the integration connection
142
     *
143
     * @return IntegrationConnectionInterface
144
     */
145
    public static function getIntegrationConnection(): IntegrationConnectionInterface
146
    {
147
        return self::$integrationConnection;
148
    }
149
150
    /**
151
     * Set the integration connection
152
     *
153
     * @param IntegrationConnectionInterface $integrationConnection
154
     */
155
    public static function setIntegrationConnection(IntegrationConnectionInterface $integrationConnection)
156
    {
157
        self::$integrationConnection = $integrationConnection;
158
    }
159
}
160