<commit_before><?php

namespace Dzangocart\Bundle\DzangocartBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class PaymentsFiltersType extends AbstractType
{
    protected $services;

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

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('order_id', 'text', array(
            'required' => false
        ));

        $builder->add('service_id', 'choice', array(
            'choices'   => $this->getGatewayServices(),
            'required' => false
        ));

        $builder->add('status', 'choice', array(
            'choices'   => array(
                0 => 'payments.status.label.open',
                2 => 'payments.status.label.cancelled',
                4 => 'payments.status.label.error',
                8 => 'payments.status.label.approved',
                16 => 'payments.status.label.paid'
            ),
            'required' => false
        ));

        $builder->add('date_from', 'date', array(
            'format' => 'yyyy-MM-dd',
            'label' => 'payments.filters.date_from',
            'widget' => 'single_text',
            'attr' => array(
                'class' => 'date_from'
            )
        ));

        $builder->add('date_to', 'date', array(
            'format' => 'yyyy-MM-dd',
            'label' => 'payments.filters.date_to',
            'widget' => 'single_text',
            'attr' => array(
                'class' => 'date_to'
            )
        ));

        $builder->add('period', 'text', array(
            'attr' => array(
                'class' => 'period'
            ),
            'label' => 'payments.filters.period'
        ));

        $builder->add('test', 'checkbox', array(
            'label' => 'payments.filters.test_payments.label',
            'attr' => array(
                'class' => 'checkbox'
            )
        ));
    }

    public function getName()
    {
        return 'filters';
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'translation_domain' => 'dzangocart'
        ));
    }

    protected function getGatewayServices()
    {
        $services = array();

        foreach ($this->services as $service) {
            $services[$service['id']] = $service['value'];
        }

        return $services;
    }

}<commit_msg>removed blank line<commit_after><?php

namespace Dzangocart\Bundle\DzangocartBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class PaymentsFiltersType extends AbstractType
{
    protected $services;

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

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('order_id', 'text', array(
            'required' => false
        ));

        $builder->add('service_id', 'choice', array(
            'choices'   => $this->getGatewayServices(),
            'required' => false
        ));

        $builder->add('status', 'choice', array(
            'choices'   => array(
                0 => 'payments.status.label.open',
                2 => 'payments.status.label.cancelled',
                4 => 'payments.status.label.error',
                8 => 'payments.status.label.approved',
                16 => 'payments.status.label.paid'
            ),
            'required' => false
        ));

        $builder->add('date_from', 'date', array(
            'format' => 'yyyy-MM-dd',
            'label' => 'payments.filters.date_from',
            'widget' => 'single_text',
            'attr' => array(
                'class' => 'date_from'
            )
        ));

        $builder->add('date_to', 'date', array(
            'format' => 'yyyy-MM-dd',
            'label' => 'payments.filters.date_to',
            'widget' => 'single_text',
            'attr' => array(
                'class' => 'date_to'
            )
        ));

        $builder->add('period', 'text', array(
            'attr' => array(
                'class' => 'period'
            ),
            'label' => 'payments.filters.period'
        ));

        $builder->add('test', 'checkbox', array(
            'label' => 'payments.filters.test_payments.label',
            'attr' => array(
                'class' => 'checkbox'
            )
        ));
    }

    public function getName()
    {
        return 'filters';
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'translation_domain' => 'dzangocart'
        ));
    }

    protected function getGatewayServices()
    {
        $services = array();

        // FIXME [JP 2014-07-21] Assumes $this->services is not empty.
        foreach ($this->services as $service) {
            $services[$service['id']] = $service['value'];
        }

        return $services;
    }
}
{'fraction_non_alphanumeric': 0.14947569113441372, 'fraction_numerical': 0.0038131553860819827, 'mean_word_length': 1.7978666666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 80, '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': '1986855', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1456, 'n_words': 258}