<commit_before><?php
/**
 * Twig extension for barcodes 
 *
 * @author <NAME><<EMAIL>>
 * @copyright 2011 <NAME>
 * @license http://www.apache.org/licenses/LICENSE-2.0.html
 */

namespace Mopa\BarcodeBundle\Twig\Extension;

use Mopa\BarcodeBundle\Model\BarcodeService;

class BarcodeRenderExtension extends \Twig_Extension {
    
    protected $bs;
    /**
     * @param \Knp\Menu\Twig\Helper $helper
     */
    public function __construct(BarcodeService $bs)
    {
        $this->bs = $bs;
    }
    /**
     * {@inheritDoc}
     */
    public function getName() {
        return 'mopa_barcode_render';
    }
    
    public function getFunctions()
    {
        return array(
            'mopa_barcode_url' => new \Twig_Function_Method($this, 'get'),
        );
    }
    public function get($type, $text){
        return $this->bs->get($type, urlencode($text));
    }
}
<commit_msg>Add new twig extension function<commit_after><?php
/**
 * Twig extension for barcodes 
 *
 * @author <NAME><<EMAIL>>
 * @copyright 2011 <NAME>
 * @license http://www.apache.org/licenses/LICENSE-2.0.html
 */

namespace Mopa\BarcodeBundle\Twig\Extension;

use Mopa\BarcodeBundle\Model\BarcodeService;

class BarcodeRenderExtension extends \Twig_Extension {
    
    protected $bs;
    /**
     * @param \Knp\Menu\Twig\Helper $helper
     */
    public function __construct(BarcodeService $bs)
    {
        $this->bs = $bs;
    }
    /**
     * {@inheritDoc}
     */
    public function getName() {
        return 'mopa_barcode_render';
    }
    
    public function getFunctions()
    {
        return array(
            'mopa_barcode_url' => new \Twig_Function_Method($this, 'url'),
		    'mopa_barcode_path' => new \Twig_Function_Method($this, 'path'),
        );
    }

    public function url($type, $text) {
        $this->get($type, $text, false);
    }

	public function path($type, $text) {
        $this->get($type, $text, true);
    }
	
	protected function get($type, $text, $absolute) {
		return $this->bs->get($type, urlencode($text), $absolute);
	}
}

{'fraction_non_alphanumeric': 0.14829268292682926, 'fraction_numerical': 0.005853658536585366, 'mean_word_length': 2.630088495575221, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 22, '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': '2221694', 'n_tokens_mistral': 697, 'n_tokens_neox': 679, 'n_words': 130}