protected function parseScopeArray(array $scopes)
    {
        $parsedScopes = [];

        foreach ($scopes as $scope) {
            if (is_string($scope) && $scope != '') {
                $parsedScopes[] = $scope;
            } else if ($scope instanceof IScope) {
                $parsedScopes[] =  $scope->getId();
            } else {
                throw new \InvalidArgumentException('Scopes has to be array of strings or OAuth2\Storage\IScope instances.');
            }
        }

        return $parsedScopes;
    }