<commit_before><?php

/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014-2015 Spomky-Labs
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

namespace SpomkyLabs\Jose\Behaviour;

use Jose\JWKInterface;

trait HasKeyChecker
{
    /**
     * @param \Jose\JWKInterface $key
     * @param string             $usage
     *
     * @throws \InvalidArgumentException
     *
     * @return bool
     */
    protected function checkKeyUsage(JWKInterface $key, $usage)
    {
        $use = $key->getPublicKeyUse();
        $ops = $key->getKeyOperations();
        if (is_null($use) && is_null($ops)) {
            return true;
        }

        if (!is_null($use)) {
            switch ($usage) {
                case 'verification':
                case 'signature':
                    if ('sig' === $use) {
                        return true;
                    }

                    throw new \InvalidArgumentException('Unsupported key usage.');
                case 'encryption':
                case 'decryption':
                    if ('enc' === $use) {<commit_msg>Bug fixed<commit_after><?php

/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014-2015 Spomky-Labs
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

namespace SpomkyLabs\Jose\Behaviour;

use Jose\JWKInterface;

trait HasKeyChecker
{
    /**
     * @param \Jose\JWKInterface $key
     * @param string             $usage
     *
     * @throws \InvalidArgumentException
     *
     * @return bool
     */
    protected function checkKeyUsage(JWKInterface $key, $usage)
    {
        $use = $key->getPublicKeyUse();
        $ops = $key->getKeyOperations();
        if (is_null($use) && is_null($ops)) {
            return true;
        }

        if (!is_null($use)) {
            switch ($usage) {
                case 'verification':
                case 'signature':
                    if ('sig' === $use) {
                        return true;
                    }

                    return false;
                case 'encryption':
                case 'decryption':
                    if ('enc' === $use) {
{'fraction_non_alphanumeric': 0.11680784663397235, 'fraction_numerical': 0.007133303611234953, 'mean_word_length': 1.5822784810126582, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7463490', 'n_tokens_mistral': 656, 'n_tokens_neox': 615, 'n_words': 166}