Completed
Push — master ( 3c3141...08c1cf )
by Ben
01:48
created
src/Former/Form/Elements.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -12,106 +12,106 @@
 block discarded – undo
12 12
  */
13 13
 class Elements
14 14
 {
15
-	/**
16
-	 * The Container
17
-	 *
18
-	 * @var Container
19
-	 */
20
-	protected $app;
21
-
22
-	/**
23
-	 * The Session instance
24
-	 *
25
-	 * @var Session
26
-	 */
27
-	protected $session;
28
-
29
-	/**
30
-	 * Build a new Element
31
-	 *
32
-	 * @param Container $app
33
-	 */
34
-	public function __construct(Container $app, $session)
35
-	{
36
-		$this->app     = $app;
37
-		$this->session = $session;
38
-	}
39
-
40
-	/**
41
-	 * Generate a hidden field containing the current CSRF token.
42
-	 *
43
-	 * @return string
44
-	 */
45
-	public function token()
46
-	{
47
-		$csrf = method_exists($this->session, 'getToken') ? $this->session->getToken() : $this->session->token();
48
-
49
-		return (string) $this->app['former']->hidden('_token', $csrf);
50
-	}
51
-
52
-	/**
53
-	 * Creates a label tag
54
-	 *
55
-	 * @param  string $label      The label content
56
-	 * @param  string $for        The field the label's for
57
-	 * @param  array  $attributes The label's attributes
58
-	 *
59
-	 * @return Element             A <label> tag
60
-	 */
61
-	public function label($label, $for = null, $attributes = array())
62
-	{
63
-		if (!$label instanceof Htmlable) {
64
-			$oldLabel = (string) $label;
65
-			$label    = Helpers::translate($oldLabel);
66
-
67
-			// If there was no change to the label,
68
-			// then a Laravel translation did not occur
69
-			if (lcfirst($label) == $oldLabel) {
70
-				$label = str_replace('_', ' ', $label);
71
-			}
72
-		} else {
73
-			$label = (string) $label->toHtml();
74
-		}
75
-
76
-		$attributes['for']             = $for;
77
-		$this->app['former']->labels[] = $for;
78
-
79
-		return Element::create('label', $label, $attributes);
80
-	}
81
-
82
-	/**
83
-	 * Creates a form legend
84
-	 *
85
-	 * @param  string $legend     The text
86
-	 * @param  array  $attributes Its attributes
87
-	 *
88
-	 * @return Element             A <legend> tag
89
-	 */
90
-	public function legend($legend, $attributes = array())
91
-	{
92
-		$legend = Helpers::translate($legend);
93
-
94
-		return Element::create('legend', $legend, $attributes);
95
-	}
96
-
97
-	/**
98
-	 * Close a field group
99
-	 *
100
-	 * @return string
101
-	 */
102
-	public function closeGroup()
103
-	{
104
-		$closing = '';
105
-		if (Group::$opened && isset(Group::$openGroup)) {
106
-			$closing = Group::$openGroup->close();
107
-		}
108
-
109
-		// Close custom group
110
-		Group::$opened = false;
111
-
112
-		// Reset custom group reference
113
-		Group::$openGroup = null;
114
-
115
-		return $closing;
116
-	}
15
+    /**
16
+     * The Container
17
+     *
18
+     * @var Container
19
+     */
20
+    protected $app;
21
+
22
+    /**
23
+     * The Session instance
24
+     *
25
+     * @var Session
26
+     */
27
+    protected $session;
28
+
29
+    /**
30
+     * Build a new Element
31
+     *
32
+     * @param Container $app
33
+     */
34
+    public function __construct(Container $app, $session)
35
+    {
36
+        $this->app     = $app;
37
+        $this->session = $session;
38
+    }
39
+
40
+    /**
41
+     * Generate a hidden field containing the current CSRF token.
42
+     *
43
+     * @return string
44
+     */
45
+    public function token()
46
+    {
47
+        $csrf = method_exists($this->session, 'getToken') ? $this->session->getToken() : $this->session->token();
48
+
49
+        return (string) $this->app['former']->hidden('_token', $csrf);
50
+    }
51
+
52
+    /**
53
+     * Creates a label tag
54
+     *
55
+     * @param  string $label      The label content
56
+     * @param  string $for        The field the label's for
57
+     * @param  array  $attributes The label's attributes
58
+     *
59
+     * @return Element             A <label> tag
60
+     */
61
+    public function label($label, $for = null, $attributes = array())
62
+    {
63
+        if (!$label instanceof Htmlable) {
64
+            $oldLabel = (string) $label;
65
+            $label    = Helpers::translate($oldLabel);
66
+
67
+            // If there was no change to the label,
68
+            // then a Laravel translation did not occur
69
+            if (lcfirst($label) == $oldLabel) {
70
+                $label = str_replace('_', ' ', $label);
71
+            }
72
+        } else {
73
+            $label = (string) $label->toHtml();
74
+        }
75
+
76
+        $attributes['for']             = $for;
77
+        $this->app['former']->labels[] = $for;
78
+
79
+        return Element::create('label', $label, $attributes);
80
+    }
81
+
82
+    /**
83
+     * Creates a form legend
84
+     *
85
+     * @param  string $legend     The text
86
+     * @param  array  $attributes Its attributes
87
+     *
88
+     * @return Element             A <legend> tag
89
+     */
90
+    public function legend($legend, $attributes = array())
91
+    {
92
+        $legend = Helpers::translate($legend);
93
+
94
+        return Element::create('legend', $legend, $attributes);
95
+    }
96
+
97
+    /**
98
+     * Close a field group
99
+     *
100
+     * @return string
101
+     */
102
+    public function closeGroup()
103
+    {
104
+        $closing = '';
105
+        if (Group::$opened && isset(Group::$openGroup)) {
106
+            $closing = Group::$openGroup->close();
107
+        }
108
+
109
+        // Close custom group
110
+        Group::$opened = false;
111
+
112
+        // Reset custom group reference
113
+        Group::$openGroup = null;
114
+
115
+        return $closing;
116
+    }
117 117
 }
Please login to merge, or discard this patch.