|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Parroauth2\Client; |
|
4
|
|
|
|
|
5
|
|
|
use Jose\Component\Core\JWKSet; |
|
6
|
|
|
use Parroauth2\Client\EndPoint\EndPoints; |
|
7
|
|
|
use Parroauth2\Client\Extension\ExtensionInterface; |
|
8
|
|
|
use Parroauth2\Client\Provider\ProviderInterface; |
|
9
|
|
|
use Parroauth2\Client\Provider\ProxyProvider; |
|
10
|
|
|
use Parroauth2\Client\Storage\StorageInterface; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Lazy loading client implementation |
|
14
|
|
|
* |
|
15
|
|
|
* @see ProxyProvider For instantiate the ProxyClient |
|
16
|
|
|
*/ |
|
17
|
|
|
final class ProxyClient implements ClientInterface |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var ClientConfig |
|
21
|
|
|
*/ |
|
22
|
|
|
private $config; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var callable(ClientConfig):ClientInterface |
|
26
|
|
|
*/ |
|
27
|
|
|
private $clientFactory; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var list<ExtensionInterface> |
|
|
|
|
|
|
31
|
|
|
*/ |
|
32
|
|
|
private $extensions = []; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var ClientInterface|null |
|
36
|
|
|
*/ |
|
37
|
|
|
private $client = null; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* ProxyClient constructor. |
|
41
|
|
|
* |
|
42
|
|
|
* @param ClientConfig $config The client configuration |
|
43
|
|
|
* @param callable(ClientConfig):ClientInterface $clientFactory |
|
44
|
|
|
*/ |
|
45
|
5 |
|
public function __construct(ClientConfig $config, callable $clientFactory) |
|
46
|
|
|
{ |
|
47
|
5 |
|
$this->config = $config; |
|
48
|
5 |
|
$this->clientFactory = $clientFactory; |
|
49
|
5 |
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* {@inheritdoc} |
|
53
|
|
|
*/ |
|
54
|
1 |
|
public function clientId(): string |
|
55
|
|
|
{ |
|
56
|
1 |
|
return $this->config->clientId(); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* {@inheritdoc} |
|
61
|
|
|
*/ |
|
62
|
1 |
|
public function secret(): ?string |
|
63
|
|
|
{ |
|
64
|
1 |
|
return $this->config->secret(); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* {@inheritdoc} |
|
69
|
|
|
*/ |
|
70
|
1 |
|
public function storage(): StorageInterface |
|
71
|
|
|
{ |
|
72
|
1 |
|
return $this->client()->storage(); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* {@inheritdoc} |
|
77
|
|
|
*/ |
|
78
|
1 |
|
public function clientConfig(): ClientConfig |
|
79
|
|
|
{ |
|
80
|
1 |
|
return $this->config; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* {@inheritdoc} |
|
85
|
|
|
*/ |
|
86
|
1 |
|
public function provider(): ProviderInterface |
|
87
|
|
|
{ |
|
88
|
1 |
|
return $this->client()->provider(); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* {@inheritdoc} |
|
93
|
|
|
*/ |
|
94
|
2 |
|
public function endPoints(): EndPoints |
|
95
|
|
|
{ |
|
96
|
2 |
|
return $this->client()->endPoints(); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* {@inheritdoc} |
|
101
|
|
|
*/ |
|
102
|
1 |
|
public function keySet(): JWKSet |
|
103
|
|
|
{ |
|
104
|
1 |
|
return $this->client()->keySet(); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* {@inheritdoc} |
|
109
|
|
|
*/ |
|
110
|
|
|
public function option(string $name, $default = null) |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->config->option($name, $default); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* {@inheritdoc} |
|
117
|
|
|
*/ |
|
118
|
2 |
|
public function register(ExtensionInterface $extension): void |
|
119
|
|
|
{ |
|
120
|
2 |
|
if ($this->client) { |
|
121
|
1 |
|
$this->client->register($extension); |
|
122
|
|
|
} else { |
|
123
|
2 |
|
$this->extensions[] = $extension; |
|
124
|
|
|
} |
|
125
|
2 |
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Resolve the real client instance |
|
129
|
|
|
* |
|
130
|
|
|
* @return ClientInterface |
|
131
|
|
|
*/ |
|
132
|
4 |
|
private function client(): ClientInterface |
|
133
|
|
|
{ |
|
134
|
4 |
|
if ($this->client) { |
|
135
|
2 |
|
return $this->client; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
4 |
|
$this->client = ($this->clientFactory)($this->config); |
|
139
|
|
|
|
|
140
|
4 |
|
foreach ($this->extensions as $extension) { |
|
141
|
1 |
|
$this->client->register($extension); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
4 |
|
unset($this->clientFactory); |
|
145
|
4 |
|
unset($this->extensions); |
|
146
|
|
|
|
|
147
|
4 |
|
return $this->client; |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths