Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
8 / 8 |
CRAP | |
100.00% |
19 / 19 |
GoogleClientWrapper | |
100.00% |
1 / 1 |
|
100.00% |
8 / 8 |
10 | |
100.00% |
19 / 19 |
make | |
100.00% |
1 / 1 |
3 | |
100.00% |
7 / 7 |
|||
__construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
3 / 3 |
|||
setAuthConfig | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
addScope | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
setSubjet | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
getClient | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
getAccessToken | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
getSubject | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
1 | <?php |
2 | |
3 | namespace Qmp\Laravel\GoogleApiWrapper\Client; |
4 | |
5 | use Google\Service\{Drive, Sheets}; |
6 | use Google\Client; |
7 | |
8 | |
9 | class GoogleClientWrapper |
10 | { |
11 | /** |
12 | * |
13 | */ |
14 | const SCOPE = [ |
15 | Drive::DRIVE, |
16 | Sheets::SPREADSHEETS |
17 | ]; |
18 | |
19 | /** |
20 | * Undocumented variable |
21 | * |
22 | * @var string |
23 | */ |
24 | protected $subject; |
25 | |
26 | /** |
27 | * Undocumented variable |
28 | * |
29 | * @var Client |
30 | */ |
31 | protected $client; |
32 | |
33 | /** |
34 | * Undocumented function |
35 | * |
36 | * @param string|null $subject |
37 | * @param array|null $authConfig |
38 | * @return self |
39 | */ |
40 | public static function make(string $subject = null, array $authConfig = null): self |
41 | { |
42 | $client = new Self($subject); |
43 | $client->addScope(self::SCOPE); |
44 | |
45 | if ($subject) { |
46 | $client->setSubjet($subject); |
47 | } |
48 | |
49 | if ($authConfig = $authConfig ?? config('google-api-wrapper.authFile')) { |
50 | $client->setAuthConfig($authConfig); |
51 | } |
52 | |
53 | return $client; |
54 | } |
55 | |
56 | |
57 | /** |
58 | * Undocumented function |
59 | * |
60 | * @param string $subject |
61 | */ |
62 | public function __construct(string $subject = "") |
63 | { |
64 | $this->subject = $subject; |
65 | $this->client = new Client; |
66 | } |
67 | |
68 | /** |
69 | * Undocumented function |
70 | * |
71 | * @param array $config |
72 | * @return self |
73 | */ |
74 | public function setAuthConfig(array $config): self |
75 | { |
76 | $this->client->setAuthConfig($config); |
77 | return $this; |
78 | } |
79 | |
80 | /** |
81 | * Undocumented function |
82 | * |
83 | * @param [type] $scope |
84 | * @return self |
85 | */ |
86 | public function addScope($scope): self |
87 | { |
88 | $this->client->addScope($scope); |
89 | return $this; |
90 | } |
91 | |
92 | /** |
93 | * Undocumented function |
94 | * |
95 | * @param string $subject |
96 | * @return self |
97 | */ |
98 | public function setSubjet(string $subject): self |
99 | { |
100 | $this->client->setSubject($subject); |
101 | return $this; |
102 | } |
103 | |
104 | /** |
105 | * Undocumented function |
106 | * |
107 | * @return Client |
108 | */ |
109 | public function getClient(): Client |
110 | { |
111 | return $this->client; |
112 | } |
113 | |
114 | /** |
115 | * @return array|null |
116 | */ |
117 | public function getAccessToken() |
118 | { |
119 | return $this->client->getAccessToken(); |
120 | } |
121 | |
122 | |
123 | /** |
124 | * Undocumented function |
125 | * |
126 | * @return string |
127 | */ |
128 | public function getSubject(): string |
129 | { |
130 | return $this->subject; |
131 | } |
132 | } |