<commit_before><?php

/**
 * This file is part of the pantarei/oauth2 package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Pantarei\Oauth2\Security\Authentication\Token;

use Pantarei\Oauth2\Model\ClientInterface;
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;

/**
 * Oauth2 ClientToken for token endpoint authentication.
 */
class ClientToken extends AbstractToken
{
    protected $client;

    protected $client_secret;

    protected $providerKey;

    public function __construct($client_id, $client_secret, $providerKey, array $roles = array())
    {
        parent::__construct($roles);

        $this->setClient($client_id);
        $this->client_secret = $client_secret;
        $this->providerKey = $providerKey;

        parent::setAuthenticated(count($roles) > 0);
    }

    public function setClient($client)
    {
        $this->client = $client;
        return $this;
    }

    public function getClient()
    {
        return $this->client;
    }

    public function getClientId()
    {
        if ($this->client instanceof ClientInterface) {
            return $this->client->getClientId();
        }

        return (string) $this->client;
    }

    public function getClientSecret()
    {
        return $this->client_secret;
    }

    public function getCredentials()
    {
        return '';
    }

    public function serialize()
    {
        return serialize(array($this->client_id, $this->client_secret, $this->providerKey, parent::serialize()));
    }

    public function unserialize($str)
    {
        list($this->client_id, $this->client_secret, $this->providerKey, $parentStr) = unserialize($str);
    }
}<commit_msg>Use of client_id in ClientToken should replace as client.<commit_after><?php

/**
 * This file is part of the pantarei/oauth2 package.
 *
 * (c) <NAME> Edison <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Pantarei\Oauth2\Security\Authentication\Token;

use Pantarei\Oauth2\Model\ClientInterface;
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;

/**
 * Oauth2 ClientToken for token endpoint authentication.
 */
class ClientToken extends AbstractToken
{
    protected $client;

    protected $client_secret;

    protected $providerKey;

    public function __construct($client_id, $client_secret, $providerKey, array $roles = array())
    {
        parent::__construct($roles);

        $this->setClient($client_id);
        $this->client_secret = $client_secret;
        $this->providerKey = $providerKey;

        parent::setAuthenticated(count($roles) > 0);
    }

    public function setClient($client)
    {
        $this->client = $client;
        return $this;
    }

    public function getClient()
    {
        return $this->client;
    }

    public function getClientId()
    {
        if ($this->client instanceof ClientInterface) {
            return $this->client->getClientId();
        }

        return (string) $this->client;
    }

    public function getClientSecret()
    {
        return $this->client_secret;
    }

    public function getCredentials()
    {
        return '';
    }

    public function serialize()
    {
        return serialize(array($this->client, $this->client_secret, $this->providerKey, parent::serialize()));
    }

    public function unserialize($str)
    {
        list($this->client, $this->client_secret, $this->providerKey, $parentStr) = unserialize($str);
    }
}
{'fraction_non_alphanumeric': 0.11949685534591195, 'fraction_numerical': 0.0027344818156959257, 'mean_word_length': 2.946062567421791, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 43, 'https://': 0, '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': '4635673', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1025, 'n_words': 245}