<commit_before><?php

namespace Jukoff\OAuth2\Client\Provider;

use League\OAuth2\Client\Provider\AbstractProvider;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Token\AccessToken;
use League\OAuth2\Client\Tool\BearerAuthorizationTrait;
use Psr\Http\Message\ResponseInterface;

class Weibo extends AbstractProvider
{
    use BearerAuthorizationTrait;

    /**
     * API url
     *
     * @var string
     */
    public $baseUrl = 'https://api.weibo.com/';

    /**
     * Current API version
     *
     * @var int
     */
    protected $currentApiVersion = 2;

    /**
     * Sets current API version
     *
     * @param int $version
     */
    public function setApiVersion($version)
    {
        $this->currentApiVersion = $version;
    }

    /**
     * Returns current API version
     *
     * @return int
     */
    public function getApiVersion()
    {
        return $this->currentApiVersion;
    }

    /**
     * {@inheritdoc}
     */
    public function getBaseAuthorizationUrl()
    {
        return $this->baseUrl . 'oauth2/authorize';
    }

    /**
     * {@inheritdoc}
     */
    public function getBaseAccessTokenUrl(array $params)
    {
        return $this->baseUrl . 'oauth2/access_token';
    }

    /**
     * {@inheritdoc}
     */
    public function getResourceOwnerDetailsUrl(AccessToken $token)
    {
        $parameters = [
            'access_token' => $token->getToken(),
        ];

        return $this->baseUrl . $this->currentApiVersion . '/users/show.json?' . http_build_query($parameters);
    }

    /**
     * {@inheritdoc}
     */
    public function getDefaultScopes()
    {
        return [];
    }

    /**
     * {@inheritdoc}
     */
    protected function checkResponse(ResponseInterface $response, $data)
    {
        if ($response->getStatusCode() >= 400) {
            throw new IdentityProviderException(
                $data['error'] ?: $response->getReasonPhrase(),
                $response->getStatusCode(),
                $response
            );
        }<commit_msg>Set api url as constant<commit_after><?php

namespace Jukoff\OAuth2\Client\Provider;

use League\OAuth2\Client\Provider\AbstractProvider;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Token\AccessToken;
use League\OAuth2\Client\Tool\BearerAuthorizationTrait;
use Psr\Http\Message\ResponseInterface;

class Weibo extends AbstractProvider
{
    use BearerAuthorizationTrait;

    /**
     * API url
     *
     * @var string
     */
    const BASE_API_URL = 'https://api.weibo.com/';

    /**
     * Current API version
     *
     * @var int
     */
    protected $currentApiVersion = 2;

    /**
     * Sets current API version
     *
     * @param int $version
     */
    public function setApiVersion($version)
    {
        $this->currentApiVersion = $version;
    }

    /**
     * Returns current API version
     *
     * @return int
     */
    public function getApiVersion()
    {
        return $this->currentApiVersion;
    }

    /**
     * {@inheritdoc}
     */
    public function getBaseAuthorizationUrl()
    {
        return self::BASE_API_URL . 'oauth2/authorize';
    }

    /**
     * {@inheritdoc}
     */
    public function getBaseAccessTokenUrl(array $params)
    {
        return self::BASE_API_URL . 'oauth2/access_token';
    }

    /**
     * {@inheritdoc}
     */
    public function getResourceOwnerDetailsUrl(AccessToken $token)
    {
        $parameters = [
            'access_token' => $token->getToken(),
        ];

        return self::BASE_API_URL . $this->currentApiVersion . '/users/show.json?' . http_build_query($parameters);
    }

    /**
     * {@inheritdoc}
     */
    public function getDefaultScopes()
    {
        return [];
    }

    /**
     * {@inheritdoc}
     */
    protected function checkResponse(ResponseInterface $response, $data)
    {
        if ($response->getStatusCode() >= 400) {
            throw new IdentityProviderException(
                $data['error'] ?: $response->getReasonPhrase(),
                $response->getStatusCode(),
                $response
            );
        }
{'fraction_non_alphanumeric': 0.12419393360401242, 'fraction_numerical': 0.005254358729400526, 'mean_word_length': 2.106824925816024, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4403176', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1210, 'n_words': 216}