<commit_before><?php
/**
 * This file is part of the PHP Rebilly API package.
 *
 * (c) 2015 Rebilly SRL
 *
 * For the full copyright and license information, please view the LICENSE.md
 * file that was distributed with this source code.
 */

namespace Rebilly\Services;

use ArrayObject;
use Rebilly\Entities\PaymentCardToken;
use Rebilly\Http\Exception\NotFoundException;
use Rebilly\Rest\Collection;
use Rebilly\Rest\Service;

/**
 * Class PaymentCardTokenService
 *
 * @author <NAME> <<EMAIL>>
 * @version 0.1
 */
final class PaymentCardTokenService extends Service
{
    /**
     * @param array|ArrayObject $params
     *
     * @return PaymentCardToken[]|Collection
     */
    public function search($params = [])
    {
        return $this->client()->get('tokens', $params);
    }

    /**
     * @param string $tokenId
     * @param array|ArrayObject $params
     *
     * @throws NotFoundException The resource data does exist
     *
     * @return PaymentCardToken
     */
    public function load($tokenId, $params = [])
    {
        return $this->client()->get('tokens/{tokenId}', ['tokenId' => $tokenId] + (array) $params);
    }
}<commit_msg>Add Token create and expire methods<commit_after><?php
/**
 * This file is part of the PHP Rebilly API package.
 *
 * (c) 2015 Rebilly SRL
 *
 * For the full copyright and license information, please view the LICENSE.md
 * file that was distributed with this source code.
 */

namespace Rebilly\Services;

use ArrayObject;
use JsonSerializable;
use Rebilly\Entities\PaymentCardToken;
use Rebilly\Http\Exception\NotFoundException;
use Rebilly\Http\Exception\UnprocessableEntityException;
use Rebilly\Rest\Collection;
use Rebilly\Rest\Service;

/**
 * Class PaymentCardTokenService
 *
 * @author <NAME> <<EMAIL>>
 * @version 0.1
 */
final class PaymentCardTokenService extends Service
{
    /**
     * @param array|JsonSerializable|PaymentCardToken $data
     * @param string $tokenId
     *
     * @throws UnprocessableEntityException The input data does not valid
     *
     * @return PaymentCardToken
     */
    public function create($data, $tokenId = null)
    {
        if (isset($tokenId)) {
            return $this->client()->put($data, 'tokens/{tokenId}', ['tokenId' => $tokenId]);
        } else {
            return $this->client()->post($data, 'tokens');
        }
    }

    /**
     * @param array|ArrayObject $params
     *
     * @return PaymentCardToken[]|Collection
     */
    public function search($params = [])
    {
        return $this->client()->get('tokens', $params);
    }

    /**
     * @param string $tokenId
     * @param array|ArrayObject $params
     *
     * @throws NotFoundException The resource data does exist
     *
     * @return PaymentCardToken
     */
    public function load($tokenId, $params = [])
    {
        return $this->client()->get('tokens/{tokenId}', ['tokenId' => $tokenId] + (array) $params);
    }

    /**
     * @param string $tokenId
     * @param array|ArrayObject $params
     *
     * @throws NotFoundException The resource data does exist
     *
     * @return PaymentCardToken
     */
    public function expire($tokenId, $params = [])
    {
        return $this->client()->post(['tokenId' => $tokenId] + (array) $params, 'tokens/'.$tokenId.'/expiration');
    }
}
{'fraction_non_alphanumeric': 0.13343465045592706, 'fraction_numerical': 0.00364741641337386, 'mean_word_length': 2.96028880866426, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '1998160', 'n_tokens_mistral': 961, 'n_tokens_neox': 966, 'n_words': 254}