|
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\hubspot\patron\connections; |
|
10
|
|
|
|
|
11
|
|
|
use flipbox\hubspot\connections\IntegrationConnectionInterface; |
|
12
|
|
|
use Flipbox\OAuth2\Client\Provider\HubSpotResourceOwner; |
|
13
|
|
|
use yii\base\BaseObject; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @author Flipbox Factory <[email protected]> |
|
17
|
|
|
* @since 1.0.0 |
|
18
|
|
|
*/ |
|
19
|
|
|
class AccessTokenConnection extends BaseObject implements IntegrationConnectionInterface |
|
20
|
|
|
{ |
|
21
|
|
|
use traits\AccessTokenAuthorizationTrait; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
private $hubId; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
private $appId; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var HubSpotResourceOwner |
|
35
|
|
|
*/ |
|
36
|
|
|
private $resourceOwner; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @inheritdoc |
|
40
|
|
|
* @throws \flipbox\ember\exceptions\NotFoundException |
|
41
|
|
|
* @throws \yii\base\InvalidConfigException |
|
42
|
|
|
*/ |
|
43
|
|
|
public function getHubId(): string |
|
44
|
|
|
{ |
|
45
|
|
|
if ($this->hubId === null) { |
|
46
|
|
|
if (null === ($hubId = $this->getFromValues('hubId'))) { |
|
|
|
|
|
|
47
|
|
|
$hubId = $this->getResourceOwner()->getHubId(); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
$this->hubId = $hubId; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
return $this->hubId; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @inheritdoc |
|
58
|
|
|
* @throws \flipbox\ember\exceptions\NotFoundException |
|
59
|
|
|
* @throws \yii\base\InvalidConfigException |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getAppId(): string |
|
62
|
|
|
{ |
|
63
|
|
|
if ($this->appId === null) { |
|
64
|
|
|
if (null === ($appId = $this->getFromValues('appId'))) { |
|
|
|
|
|
|
65
|
|
|
$appId = $this->getResourceOwner()->getAppId(); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
$this->appId = $appId; |
|
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return $this->appId; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param string $attribute |
|
76
|
|
|
* @return null |
|
77
|
|
|
* @throws \flipbox\ember\exceptions\NotFoundException |
|
78
|
|
|
* @throws \yii\base\InvalidConfigException |
|
79
|
|
|
*/ |
|
80
|
|
|
protected function getFromValues(string $attribute) |
|
81
|
|
|
{ |
|
82
|
|
|
$values = $this->getAccessToken()->getValues(); |
|
83
|
|
|
return $values[$attribute] ?? null; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @return HubSpotResourceOwner |
|
88
|
|
|
* @throws \flipbox\ember\exceptions\NotFoundException |
|
89
|
|
|
* @throws \yii\base\InvalidConfigException |
|
90
|
|
|
*/ |
|
91
|
|
|
protected function getResourceOwner() |
|
92
|
|
|
{ |
|
93
|
|
|
if ($this->resourceOwner === null) { |
|
94
|
|
|
$this->resourceOwner = $this->getProvider()->getResourceOwner($this->getAccessToken()); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
return $this->resourceOwner; |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.