<commit_before><?php namespace Watson\BootstrapForm;

use Illuminate\Config\Repository as Config;
use Illuminate\Html\HtmlBuilder;
use Illuminate\Html\FormBuilder;
use Illuminate\Session\SessionManager as Session;
use Illuminate\Support\Str;

class BootstrapForm
{
    /**
     * Illuminate HtmlBuilder instance.
     *
     * @var \Illuminate\Html\FHtmlBuilder
     */
    protected $html;

    /**
     * Illuminate FormBuilder instance.
     *
     * @var \Illuminate\Html\FormBuilder
     */
	protected $form;

    /**
     * Illuminate Repository instance.
     *
     * @var \Illuminate\Config\Repository
     */
    protected $config;

    /**
     * Illuminate SessionManager instance.
     *
     * @var \Illuminate\Session\Store
     */
    protected $session;

	public function __construct(HtmlBuilder $html, FormBuilder $form, Config $config, Session $session)
	{
        $this->html = $html;
		$this->form = $form;
        $this->config = $config;
        $this->session = $session;
	}

    /**
     * Open a form while passing a model and the routes for storing or updating 
     * the model. This will set the correct route along with the correct 
     * method.
     *
     * @param  array  $options
     * @return string
     */
    public function open(array $options = array())
    {
        $options = $this->parseModelBinding($options);

        // Set the HTML5 role.
        $options['role'] = 'form';

        // If the class hasn't been set, set the default style.
        if ( ! isset($options['class']))
        {
            $defaultForm = $this->getDefaultForm();

            if ($defaultForm === 'horizontal')
            {
                $options['class'] = 'form-horizontal';
            }
            else if ($defaultForm === 'inline')
            {
                $options['class'] = 'form-inline';
            }
        }

        return $this->form->open($options);
    }

    /**
     * Parse the model binding and set the appropriate keys for
     * routing.
     *
     * @param  array  $options
     * @return array
     */
    protected function parseModelBinding($options)
    {
        // If the form is passed a model, we'll use the update route to update 
        // the model using the PUT method.
        if (isset($options['model']) && $options['model']->getKey())
        {
            $options['route'] = array($options['update'], $options['model']->getKey());
            $options['method'] = 'put';
        }
        // Otherwise, we're storing a brand new model using the POST method.
        else if (isset($options['store']))
        {
            $options['route'] = $options['store'];
            $options['method'] = 'post';
        }

        // Forget the routes provided to the input.
        array_forget($options, 'update');
        array_forget($options, 'create');

        return $options;
    }

    public function openStandard(array $options = array())
    {
        $options = array_merge(array('class' => ''), $options);

        return $this->open($options);
    }

    /**
     * Open an inline Bootstrap form.
     *
     * @param  array  $options
     * @return string
     */
    public function openInline(array $options = array())
    {
        $options = array_merge(array('class' => 'form-inline'), $options);

        return $this->open($options);
    }

    /**
     * Open a horizontal Bootstrap form.
     *
     * @param  array  $options
     * @return string
     */
    public function openHorizontal(array $options = array())
    {
        $options = array_merge(array('class' => 'form-horizontal'), $options);

        return $this->open($options);
    }

    /**
     * Create a Bootstrap text field input.
     *
     * @param  string  $name
     * @param  string  $label
     * @param  string  $value
     * @param  array   $options
     * @return string
     */
    public function text($name, $label = null, $value = null, $options = array())
    {
        return $this->input('text', $name, $label, $value, $options);
    }

    /**
     * Create a Bootstrap email field input.
     *
     * @param  string  $name
     * @param  string  $label
     * @param  string  $value
     * @param  array   $options
     * @return string
     */
    public function email($name = 'email', $label = null, $value = null, $options = array())
    {<commit_msg>Add option for a static field<commit_after><?php namespace Watson\BootstrapForm;

use Illuminate\Config\Repository as Config;
use Illuminate\Html\HtmlBuilder;
use Illuminate\Html\FormBuilder;
use Illuminate\Session\SessionManager as Session;
use Illuminate\Support\Str;

class BootstrapForm
{
    /**
     * Illuminate HtmlBuilder instance.
     *
     * @var \Illuminate\Html\FHtmlBuilder
     */
    protected $html;

    /**
     * Illuminate FormBuilder instance.
     *
     * @var \Illuminate\Html\FormBuilder
     */
	protected $form;

    /**
     * Illuminate Repository instance.
     *
     * @var \Illuminate\Config\Repository
     */
    protected $config;

    /**
     * Illuminate SessionManager instance.
     *
     * @var \Illuminate\Session\Store
     */
    protected $session;

	public function __construct(HtmlBuilder $html, FormBuilder $form, Config $config, Session $session)
	{
        $this->html = $html;
		$this->form = $form;
        $this->config = $config;
        $this->session = $session;
	}

    /**
     * Open a form while passing a model and the routes for storing or updating 
     * the model. This will set the correct route along with the correct 
     * method.
     *
     * @param  array  $options
     * @return string
     */
    public function open(array $options = array())
    {
        $options = $this->parseModelBinding($options);

        // Set the HTML5 role.
        $options['role'] = 'form';

        // If the class hasn't been set, set the default style.
        if ( ! isset($options['class']))
        {
            $defaultForm = $this->getDefaultForm();

            if ($defaultForm === 'horizontal')
            {
                $options['class'] = 'form-horizontal';
            }
            else if ($defaultForm === 'inline')
            {
                $options['class'] = 'form-inline';
            }
        }

        return $this->form->open($options);
    }

    /**
     * Parse the model binding and set the appropriate keys for
     * routing.
     *
     * @param  array  $options
     * @return array
     */
    protected function parseModelBinding($options)
    {
        // If the form is passed a model, we'll use the update route to update 
        // the model using the PUT method.
        if (isset($options['model']) && $options['model']->getKey())
        {
            $options['route'] = array($options['update'], $options['model']->getKey());
            $options['method'] = 'put';
        }
        // Otherwise, we're storing a brand new model using the POST method.
        else if (isset($options['store']))
        {
            $options['route'] = $options['store'];
            $options['method'] = 'post';
        }

        // Forget the routes provided to the input.
        array_forget($options, 'update');
        array_forget($options, 'create');

        return $options;
    }

    public function openStandard(array $options = array())
    {
        $options = array_merge(array('class' => ''), $options);

        return $this->open($options);
    }

    /**
     * Open an inline Bootstrap form.
     *
     * @param  array  $options
     * @return string
     */
    public function openInline(array $options = array())
    {
        $options = array_merge(array('class' => 'form-inline'), $options);

        return $this->open($options);
    }

    /**
     * Open a horizontal Bootstrap form.
     *
     * @param  array  $options
     * @return string
     */
    public function openHorizontal(array $options = array())
    {
        $options = array_merge(array('class' => 'form-horizontal'), $options);

        return $this->open($options);
    }

    public function staticField($name, $label = null, $value = null, $options = array())
    {
        $options = array_merge(['class' => 'form-control-static'], $options);

        return $this->text($name, $label, $value, $options);
    }

    /**
     * Create a Bootstrap text field input.
     *
     * @param  string  $name
     * @param  string  $label
     * @param  string  $value
     * @param  array   $options
     * @return string
     */
    public function text($name, $label = null, $value = null, $options = array())
    {
        return $this->input('text', $name, $label, $value, $options);
    }

    /**
     * Create a Bootstrap email field input.
     *
     * @param  string  $name
     * @param  string  $label
     * @param  string  $value
     * @param  array   $options
     * @return string
     */
    public function email($name = 'email', $label = null, $value = null, $options = array())
    {
{'fraction_non_alphanumeric': 0.13611980330800177, 'fraction_numerical': 0.00022351363433169424, 'mean_word_length': 2.0626283367556466, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '6472881', 'n_tokens_mistral': 2531, 'n_tokens_neox': 2516, 'n_words': 687}