2017-10-04 17:12:48 +05:30
|
|
|
<?php
|
2019-07-15 04:29:56 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
2017-10-04 17:12:48 +05:30
|
|
|
namespace api\components\OAuth2\Utils;
|
|
|
|
|
|
|
|
class Scopes {
|
|
|
|
|
|
|
|
/**
|
2019-07-15 04:29:56 +05:30
|
|
|
* In the earlier versions of Accounts Ely.by backend we had a comma-separated scopes
|
|
|
|
* list, while by OAuth2 standard it they should be separated by a space. Shit happens :)
|
|
|
|
* So override scopes validation function to reformat passed value.
|
2017-10-04 17:12:48 +05:30
|
|
|
*
|
|
|
|
* @param string|array $scopes
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function format($scopes): string {
|
|
|
|
if ($scopes === null) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_array($scopes)) {
|
|
|
|
return implode(' ', $scopes);
|
|
|
|
}
|
|
|
|
|
|
|
|
return str_replace(',', ' ', $scopes);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|