<commit_before><?php
/**
 * Created by PhpStorm.
 * User: mustafa
 * Date: 6/16/14
 * Time: 10:34 AM
 */

namespace Gamegos\JWS\Algorithm;

class RSA_SSA_PKCSv15 implements AlgorithmInterface
{
    protected $sigAlgo;

    public function __construct($sigAlgo)
    {
        $this->sigAlgo = $sigAlgo;
    }

    /**
     * @param  string $key  PEM encoded private key
     * @param  mixed  $data
     * @return mixed
     */
    public function sign($key, $data)
    {
        openssl_sign($data, $signature, $key, $this->sigAlgo);

        return $signature;
    }

    /**<commit_msg>added exception for silent openssl_sign errors<commit_after><?php

namespace Gamegos\JWS\Algorithm;

class RSA_SSA_PKCSv15 implements AlgorithmInterface
{
    protected $sigAlgo;

    public function __construct($sigAlgo)
    {
        $this->sigAlgo = $sigAlgo;
    }

    /**
     * @param  string $key  PEM encoded private key
     * @param  mixed  $data
     * @return mixed
     */
    public function sign($key, $data)
    {
        $result = openssl_sign($data, $signature, $key, $this->sigAlgo);
        if (!$result) {
            throw new \RuntimeException(openssl_error_string());
        }
        return $signature;
    }

    /**
{'fraction_non_alphanumeric': 0.12022745735174654, 'fraction_numerical': 0.010560519902518278, 'mean_word_length': 2.450980392156863, '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': '5543696', 'n_tokens_mistral': 415, 'n_tokens_neox': 395, 'n_words': 93}