public static function pull($config = null, $clientId = null)
{
// Return if not enabled
if (!self::isEnabled($config)) {
return null;
}
$tokens = null;
$cachePath = self::cachePath($config);
if (file_exists($cachePath)) {
// Read from the file
$cachedToken = file_get_contents($cachePath);
if ($cachedToken && JsonValidator::validate($cachedToken, true)) {
$tokens = json_decode($cachedToken, true);
if ($clientId && is_array($tokens) && array_key_exists($clientId, $tokens)) {
// If client Id is found, just send in that data only
return $tokens[$clientId];
} elseif ($clientId) {
// If client Id is provided, but no key in persisted data found matching it.
return null;
}
}
}
return $tokens;
}