PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
← All changes | includes/sdk/google/google/auth/src/CredentialSource/FileSource.php +22 -11 1.2.91.4.1 View file →
@@ -14,11 +14,11 @@
14 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 15 * See the License for the specific language governing permissions and
16 16 * limitations under the License.
17 17 */
18 -namespace Dudlewebs\WPMCS\Google\Auth\CredentialSource;
18 +namespace Dudlewebs\WPMCS\GCP\Google\Auth\CredentialSource;
19 19
20 -use Dudlewebs\WPMCS\Google\Auth\ExternalAccountCredentialSourceInterface;
20 +use Dudlewebs\WPMCS\GCP\Google\Auth\ExternalAccountCredentialSourceInterface;
21 21 use InvalidArgumentException;
22 22 use UnexpectedValueException;
23 23 /**
24 24 * Retrieve a token from a file.
@@ -28,27 +28,27 @@
28 28 private string $file;
29 29 private ?string $format;
30 30 private ?string $subjectTokenFieldName;
31 31 /**
32 - * @param string $file The file to read the subject token from.
33 - * @param string $format The format of the token in the file. Can be null or "json".
34 - * @param string $subjectTokenFieldName The name of the field containing the token in the file. This is required
35 - * when format is "json".
32 + * @param string $file The file to read the subject token from.
33 + * @param string|null $format The format of the token in the file. Can be null or "json".
34 + * @param string|null $subjectTokenFieldName The name of the field containing the token in the file. This is required
35 + * when format is "json".
36 36 */
37 - public function __construct(string $file, string $format = null, string $subjectTokenFieldName = null)
37 + public function __construct(string $file, ?string $format = null, ?string $subjectTokenFieldName = null)
38 38 {
39 39 $this->file = $file;
40 - if ($format === 'json' && is_null($subjectTokenFieldName)) {
40 + if ($format === 'json' && \is_null($subjectTokenFieldName)) {
41 41 throw new InvalidArgumentException('subject_token_field_name must be set when format is JSON');
42 42 }
43 43 $this->format = $format;
44 44 $this->subjectTokenFieldName = $subjectTokenFieldName;
45 45 }
46 - public function fetchSubjectToken(callable $httpHandler = null): string
46 + public function fetchSubjectToken(?callable $httpHandler = null) : string
47 47 {
48 - $contents = file_get_contents($this->file);
48 + $contents = \file_get_contents($this->file);
49 49 if ($this->format === 'json') {
50 - if (!$json = json_decode((string) $contents, \true)) {
50 + if (!($json = \json_decode((string) $contents, \true))) {
51 51 throw new UnexpectedValueException('Unable to decode JSON file');
52 52 }
53 53 if (!isset($json[$this->subjectTokenFieldName])) {
54 54 throw new UnexpectedValueException('subject_token_field_name not found in JSON file');
@@ -55,6 +55,17 @@
55 55 }
56 56 $contents = $json[$this->subjectTokenFieldName];
57 57 }
58 58 return $contents;
59 + }
60 + /**
61 + * Gets the unique key for caching.
62 + * The format for the cache key one of the following:
63 + * Filename
64 + *
65 + * @return string
66 + */
67 + public function getCacheKey() : ?string
68 + {
69 + return $this->file;
59 70 }
60 71 }