<commit_before><?php
namespace Acelaya\QrCode\Service;

use Acelaya\QrCode\Exception\InvalidExtensionException;
use Endroid\QrCode\QrCode;
use Zend\Mvc\Controller\Plugin\Params;

/**
 * Class QrCodeService
 * @author <NAME>
 * @link http://www.alejandrocelaya.com
 */
class QrCodeService implements QrCodeServiceInterface
{
    /**
     * Generates the content-type corresponding to the provided extension
     * @param $extension
     * @return string
     * @throws InvalidExtensionException
     */
    public function generateContentType($extension)
    {
        if (!in_array($extension, InvalidExtensionException::getValidExtensions())) {
            throw InvalidExtensionException::fromExtension($extension);
        }

        return sprintf('image/%s', $extension == self::DEFAULT_EXTENSION ? 'jpeg' : $extension);
    }

    /**
     * Returns a QrCode content to be rendered or saved
     * @param string|Params $messageOrParams
     * @param string $extension
     * @param int $size
     * @return mixed
     */
    public function getQrCodeContent($messageOrParams, $extension = self::DEFAULT_EXTENSION, $size = self::DEFAULT_SIZE)
    {
        if ($messageOrParams instanceof Params) {
            $extension          = $messageOrParams->fromRoute('extension', QrCodeServiceInterface::DEFAULT_EXTENSION);
            $size               = $messageOrParams->fromRoute('size', QrCodeServiceInterface::DEFAULT_SIZE);
            $messageOrParams    = $messageOrParams->fromRoute('message');
        }

        $qrCode = new QrCode($messageOrParams);
        $qrCode->setImageType($extension);
        $qrCode->setSize($size);
        return $qrCode->get();<commit_msg>QrCodeService now makes sure the extension and size are set and uses default values otherwise<commit_after><?php
namespace Acelaya\QrCode\Service;

use Acelaya\QrCode\Exception\InvalidExtensionException;
use Endroid\QrCode\QrCode;
use Zend\Mvc\Controller\Plugin\Params;

/**
 * Class QrCodeService
 * @author <NAME>
 * @link http://www.ale<EMAIL>
 */
class QrCodeService implements QrCodeServiceInterface
{
    /**
     * Generates the content-type corresponding to the provided extension
     * @param $extension
     * @return string
     * @throws InvalidExtensionException
     */
    public function generateContentType($extension)
    {
        if (!in_array($extension, InvalidExtensionException::getValidExtensions())) {
            throw InvalidExtensionException::fromExtension($extension);
        }

        return sprintf('image/%s', $extension == self::DEFAULT_EXTENSION ? 'jpeg' : $extension);
    }

    /**
     * Returns a QrCode content to be rendered or saved
     * @param string|Params $messageOrParams
     * @param string $extension
     * @param int $size
     * @return mixed
     */
    public function getQrCodeContent($messageOrParams, $extension = self::DEFAULT_EXTENSION, $size = self::DEFAULT_SIZE)
    {
        if ($messageOrParams instanceof Params) {
            $extension          = $messageOrParams->fromRoute('extension', QrCodeServiceInterface::DEFAULT_EXTENSION);
            $size               = $messageOrParams->fromRoute('size', QrCodeServiceInterface::DEFAULT_SIZE);
            $messageOrParams    = $messageOrParams->fromRoute('message');
        }

        $qrCode = new QrCode($messageOrParams);
        $qrCode->setImageType(isset($extension) ? $extension : self::DEFAULT_EXTENSION);
        $qrCode->setSize(isset($size) ? $size : self::DEFAULT_SIZE);
        return $qrCode->get();
{'fraction_non_alphanumeric': 0.11395282750781471, 'fraction_numerical': 0.0, 'mean_word_length': 3.345679012345679, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2203988', 'n_tokens_mistral': 968, 'n_tokens_neox': 955, 'n_words': 203}