8
8
/**
9
9
* Provides a URL input field
10
10
*/
11
- class UrlField extends TextField {
11
+ class UrlField extends TextField
12
+ {
12
13
13
14
use Core;
14
15
use Datalist;
@@ -28,7 +29,8 @@ class UrlField extends TextField {
28
29
/**
29
30
* @inheritdoc
30
31
*/
31
- public function Type () {
32
+ public function Type ()
33
+ {
32
34
return 'url text ' ;
33
35
}
34
36
@@ -86,7 +88,8 @@ public function validate($validator)
86
88
return true ;
87
89
}
88
90
89
- public function setRequiredParts (array $ requiredParts ) {
91
+ public function setRequiredParts (array $ requiredParts )
92
+ {
90
93
$ this ->requiredParts = $ requiredParts ;
91
94
return $ this ;
92
95
}
@@ -95,7 +98,8 @@ public function setRequiredParts(array $requiredParts) {
95
98
* Parse a possible URL string
96
99
* If the second parameter is provided, the URL must have those parts
97
100
*/
98
- public function parseURL (string $ url ) : bool {
101
+ public function parseURL (string $ url ) : bool
102
+ {
99
103
if ($ url == '' ) {
100
104
// an empty URL is a valid URL
101
105
return true ;
@@ -104,7 +108,7 @@ public function parseURL(string $url) : bool {
104
108
$ parts = parse_url ($ url );
105
109
if (empty ($ this ->requiredParts )) {
106
110
return !empty ($ parts );
107
- } else {
111
+ } else {
108
112
// ensure all of the required parts are present in all of the keys
109
113
$ result = array_intersect ($ this ->requiredParts , array_keys ($ parts ));
110
114
sort ($ result );
@@ -116,19 +120,22 @@ public function parseURL(string $url) : bool {
116
120
/**
117
121
* Schemes are set by calling restrictToSchemes
118
122
*/
119
- protected function setSchemes (array $ schemes ) {
123
+ protected function setSchemes (array $ schemes )
124
+ {
120
125
$ this ->schemes = $ schemes ;
121
126
return $ this ;
122
127
}
123
128
124
- public function getSchemes () {
129
+ public function getSchemes ()
130
+ {
125
131
return $ this ->schemes ;
126
132
}
127
133
128
134
/**
129
135
* Restrict to http (and https) protocols
130
136
*/
131
- public function restrictToHttp () {
137
+ public function restrictToHttp ()
138
+ {
132
139
$ this ->restrictToSchemes (["https " ,"http " ]);
133
140
$ this ->setAttribute (
134
141
'placeholder ' ,
@@ -143,14 +150,16 @@ public function restrictToHttp() {
143
150
/**
144
151
* Restrict to URLs beginning with https://
145
152
*/
146
- public function restrictToHttps () {
153
+ public function restrictToHttps ()
154
+ {
147
155
return $ this ->restrictToSchemes (["https " ]);
148
156
}
149
157
150
158
/**
151
159
* Restrict to URLs beginning with the provided scheme
152
160
*/
153
- public function restrictToSchemes (array $ schemes ) {
161
+ public function restrictToSchemes (array $ schemes )
162
+ {
154
163
$ this ->setSchemes ($ schemes );
155
164
$ schemesString = implode ("://, " , $ schemes ) . ":// " ;
156
165
$ this ->setAttribute (
0 commit comments