1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Passbook package. |
5
|
|
|
* |
6
|
|
|
* (c) Eymen Gunay <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Passbook; |
13
|
|
|
|
14
|
|
|
use BadMethodCallException; |
15
|
|
|
use Firebase\JWT\JWT; |
16
|
|
|
use Google\Client as GoogleClient; |
17
|
|
|
use Google\Service; |
18
|
|
|
use Google\Service\Walletobjects; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* GooglePassFactory - Creates Google Wallet passes via the API |
22
|
|
|
* |
23
|
|
|
* @author Razvan Grigore <[email protected]> |
24
|
|
|
* @see https://developers.google.com/wallet/generic/web/prerequisites |
25
|
|
|
*/ |
26
|
|
|
class GooglePassFactory |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* An Issuer account is necessary to create and distribute passes for Google Wallet. |
30
|
|
|
* @see https://goo.gle/wallet-console |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
public string $issuerId; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
public string $classSuffix; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Google Wallet service client. |
42
|
|
|
*/ |
43
|
|
|
protected Walletobjects $service; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param string $issuerId Google Issuer ID |
47
|
|
|
* @param string $classSuffix |
48
|
|
|
* |
49
|
|
|
* Required. The unique identifier for the class. This ID must be unique across all from an issuer. |
50
|
|
|
* This value needs to follow the format `issuerID.identifier` where `issuerID` is issued by Google and `identifier` is chosen by you. |
51
|
|
|
* The unique identifier can only include alphanumeric characters, `.`, `_`, or `-`." |
52
|
|
|
* |
53
|
|
|
* @param Client|array $clientOrConfig The client used to deliver requests, or a |
|
|
|
|
54
|
|
|
* config array to pass to a new Client instance. |
55
|
|
|
* @param string|array $credentials |
56
|
|
|
* |
57
|
|
|
* Can be a path to JSON credentials or an array representing those |
58
|
|
|
* credentials (@see Google\Client::setAuthConfig), or an instance of |
59
|
|
|
* Google\Auth\CredentialsLoader like Google\Auth\Credentials\ServiceAccountCredentials. |
60
|
|
|
* |
61
|
|
|
* @return void |
62
|
|
|
*/ |
63
|
|
|
public function __construct(string $issuerId, string $classSuffix, $clientOrConfig, $credentials) |
64
|
|
|
{ |
65
|
|
|
$this->issuerId = $issuerId; |
66
|
|
|
$this->classSuffix = $classSuffix; |
67
|
|
|
|
68
|
|
|
// Google\Client configuration |
69
|
|
|
if (is_array($clientOrConfig)) { |
70
|
|
|
// application name is included in the User-Agent HTTP header |
71
|
|
|
$clientOrConfig['application_name'] = 'php-passbook'; |
72
|
|
|
$clientOrConfig['credentials'] = $credentials; |
73
|
|
|
$clientOrConfig['scopes'] = Walletobjects::WALLET_OBJECT_ISSUER; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$this->service = new Walletobjects($clientOrConfig); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Not implemented. Please use the constructor instead. |
81
|
|
|
* @throws BadMethodCallException |
82
|
|
|
*/ |
83
|
|
|
public function setClient(GoogleClient $client): self |
|
|
|
|
84
|
|
|
{ |
85
|
|
|
throw new \BadMethodCallException('Not implemented'); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Return Google API Client |
90
|
|
|
*/ |
91
|
|
|
public function getClient(): GoogleClient |
92
|
|
|
{ |
93
|
|
|
return $this->service->getClient(); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Not implemented. Please use the constructor instead. |
98
|
|
|
* @throws BadMethodCallException |
99
|
|
|
*/ |
100
|
|
|
public function setService(Service $service): self |
|
|
|
|
101
|
|
|
{ |
102
|
|
|
throw new \BadMethodCallException('Not implemented'); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Return Google Wallet service client. |
107
|
|
|
*/ |
108
|
|
|
public function getService(): Walletobjects |
109
|
|
|
{ |
110
|
|
|
return $this->service; |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
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