<commit_before><?php

namespace BigFish\Hub3\Api;

use BigFish\PDF417\PDF417;
use BigFish\PDF417\Renderers\ImageRenderer;

/**
 * Interfaces with PDF417 lib to create the barcode.
 */
class Worker
{
    private $renderers = [
        "image" => ImageRenderer::class
    ];

    public function render($renderer, $options, $data)
    {
        // Convert JSON to a string by HUB3 standard
        $model = Model\TransactionData::fromObject($data);
        $string = $model->toString();

        // Encode barcode data
        $pdf417 = new PDF417();

        // Settings required by HUB3 spec
        $pdf417->securityLevel(4);
        $pdf417->columns(9);

        $barcodeData = $pdf417->encode($string);

        // Render
        $renderer = $this->getRenderer($renderer, $options);
        $barcode = $renderer->render($barcodeData);
        $contentType = $renderer->getContentType();

        return [$barcode, $contentType];
    }

    public function rendererExists($name)
    {
        return isset($this->renderers);
    }

    protected function getRenderer($name, array $options = [])
    {
        if (!isset($this->renderers[$name])) {
            throw new \InvalidArgumentException("Unknown renderer \"$renderer\".");
        }

        $class = $this->renderers[$name];

        return new $class($options);
    }
}
<commit_msg>Fixing for changes in pdf417 lib<commit_after><?php

namespace BigFish\Hub3\Api;

use BigFish\PDF417\PDF417;
use BigFish\PDF417\Renderers\ImageRenderer;

/**
 * Interfaces with PDF417 lib to create the barcode.
 */
class Worker
{
    private $renderers = [
        "image" => ImageRenderer::class
    ];

    public function render($renderer, $options, $data)
    {
        // Convert JSON to a string by HUB3 standard
        $model = Model\TransactionData::fromObject($data);
        $string = $model->toString();

        // Encode barcode data
        $pdf417 = new PDF417();

        // Settings required by HUB3 spec
        $pdf417->setSecurityLevel(4);
        $pdf417->setColumns(9);

        $barcodeData = $pdf417->encode($string);

        // Render
        $renderer = $this->getRenderer($renderer, $options);
        $barcode = $renderer->render($barcodeData);
        $contentType = $renderer->getContentType();

        return [$barcode, $contentType];
    }

    public function rendererExists($name)
    {
        return isset($this->renderers);
    }

    protected function getRenderer($name, array $options = [])
    {
        if (!isset($this->renderers[$name])) {
            throw new \InvalidArgumentException("Unknown renderer \"$renderer\".");
        }

        $class = $this->renderers[$name];

        return new $class($options);
    }
}

{'fraction_non_alphanumeric': 0.13922651933701657, 'fraction_numerical': 0.024677716390423574, 'mean_word_length': 2.5364583333333335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '2171206', 'n_tokens_mistral': 834, 'n_tokens_neox': 785, 'n_words': 177}