Completed
Push — master ( 411df4...9281ef )
by Jean-Christophe
03:04
created
Ajax/semantic/components/validation/Rule.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @version 1.001
6 6
  * Generates a JSON Rule for the validation of a field
7 7
  */
8
-class Rule implements \JsonSerializable{
8
+class Rule implements \JsonSerializable {
9 9
 	/**
10 10
 	 * @var string
11 11
 	 */
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	private $value;
22 22
 
23
-	public function __construct($type,$prompt=NULL,$value=NULL){
23
+	public function __construct($type, $prompt=NULL, $value=NULL) {
24 24
 		$this->type=$type;
25 25
 		$this->prompt=$prompt;
26 26
 		$this->value=$value;
@@ -54,76 +54,76 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 
56 56
 	public function jsonSerialize() {
57
-		$result= ["type"=>$this->type];
58
-		if(isset($this->prompt))
57
+		$result=["type"=>$this->type];
58
+		if (isset($this->prompt))
59 59
 			$result["prompt"]=$this->prompt;
60
-		if(isset($this->value))
60
+		if (isset($this->value))
61 61
 			$result["value"]=$this->value;
62 62
 		return $result;
63 63
 	}
64 64
 
65
-	public static function match($name,$prompt=NULL){
66
-		return new Rule("match[".$name."]",$prompt);
65
+	public static function match($name, $prompt=NULL) {
66
+		return new Rule("match[".$name."]", $prompt);
67 67
 	}
68 68
 
69
-	public static function integer($min=0,$max=100,$prompt=NULL){
70
-		return new Rule("integer[{$min}..{$max}]",$prompt);
69
+	public static function integer($min=0, $max=100, $prompt=NULL) {
70
+		return new Rule("integer[{$min}..{$max}]", $prompt);
71 71
 	}
72 72
 
73
-	public static function decimal($prompt=NULL){
74
-		return new Rule("decimal",$prompt);
73
+	public static function decimal($prompt=NULL) {
74
+		return new Rule("decimal", $prompt);
75 75
 	}
76 76
 
77
-	public static function number($prompt=NULL){
78
-		return new Rule("number",$prompt);
77
+	public static function number($prompt=NULL) {
78
+		return new Rule("number", $prompt);
79 79
 	}
80 80
 
81
-	public static function is($value,$prompt=NULL){
82
-		return new Rule("is[".$value."]",$prompt);
81
+	public static function is($value, $prompt=NULL) {
82
+		return new Rule("is[".$value."]", $prompt);
83 83
 	}
84 84
 
85
-	public static function isExactly($value,$prompt=NULL){
86
-		return new Rule("isExactly[".$value."]",$prompt);
85
+	public static function isExactly($value, $prompt=NULL) {
86
+		return new Rule("isExactly[".$value."]", $prompt);
87 87
 	}
88 88
 
89
-	public static function not($value,$prompt=NULL){
90
-		return new Rule("not[".$value."]",$prompt);
89
+	public static function not($value, $prompt=NULL) {
90
+		return new Rule("not[".$value."]", $prompt);
91 91
 	}
92 92
 
93
-	public static function notExactly($value,$prompt=NULL){
94
-		return new Rule("notExactly[".$value."]",$prompt);
93
+	public static function notExactly($value, $prompt=NULL) {
94
+		return new Rule("notExactly[".$value."]", $prompt);
95 95
 	}
96 96
 
97
-	public static function contains($value,$prompt=NULL){
98
-		return new Rule("contains[".$value."]",$prompt);
97
+	public static function contains($value, $prompt=NULL) {
98
+		return new Rule("contains[".$value."]", $prompt);
99 99
 	}
100 100
 
101
-	public static function containsExactly($value,$prompt=NULL){
102
-		return new Rule("containsExactly[".$value."]",$prompt);
101
+	public static function containsExactly($value, $prompt=NULL) {
102
+		return new Rule("containsExactly[".$value."]", $prompt);
103 103
 	}
104 104
 
105
-	public static function doesntContain($value,$prompt=NULL){
106
-		return new Rule("doesntContain[".$value."]",$prompt);
105
+	public static function doesntContain($value, $prompt=NULL) {
106
+		return new Rule("doesntContain[".$value."]", $prompt);
107 107
 	}
108 108
 
109
-	public static function doesntContainExactly($value,$prompt=NULL){
110
-		return new Rule("doesntContainExactly[".$value."]",$prompt);
109
+	public static function doesntContainExactly($value, $prompt=NULL) {
110
+		return new Rule("doesntContainExactly[".$value."]", $prompt);
111 111
 	}
112 112
 
113
-	public static function minCount($value,$prompt=NULL){
114
-		return new Rule("minCount[".$value."]",$prompt);
113
+	public static function minCount($value, $prompt=NULL) {
114
+		return new Rule("minCount[".$value."]", $prompt);
115 115
 	}
116 116
 
117
-	public static function maxCount($value,$prompt=NULL){
118
-		return new Rule("maxCount[".$value."]",$prompt);
117
+	public static function maxCount($value, $prompt=NULL) {
118
+		return new Rule("maxCount[".$value."]", $prompt);
119 119
 	}
120 120
 
121
-	public static function exactCount($value,$prompt=NULL){
122
-		return new Rule("exactCount[".$value."]",$prompt);
121
+	public static function exactCount($value, $prompt=NULL) {
122
+		return new Rule("exactCount[".$value."]", $prompt);
123 123
 	}
124 124
 
125
-	public static function email($prompt=NULL){
126
-		return new Rule("email",$prompt);
125
+	public static function email($prompt=NULL) {
126
+		return new Rule("email", $prompt);
127 127
 	}
128 128
 
129 129
 }
130 130
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlForm.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 
32 32
 	public function __construct($identifier, $elements=array()) {
33 33
 		parent::__construct($identifier, "form", "ui form");
34
-		$this->_states=[ State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED ];
34
+		$this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED];
35 35
 		$this->setProperty("name", $this->identifier);
36
-		$this->_fields=array ();
36
+		$this->_fields=array();
37 37
 		$this->_validationParams=[];
38 38
 		$this->addItems($elements);
39 39
 	}
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 	 * @param string $caption
56 56
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
57 57
 	 */
58
-	public function addDivider($caption=NULL){
59
-		return $this->addContent(new HtmlDivider("",$caption));
58
+	public function addDivider($caption=NULL) {
59
+		return $this->addContent(new HtmlDivider("", $caption));
60 60
 	}
61 61
 
62 62
 	public function addFields($fields=NULL, $label=NULL) {
63 63
 		if (isset($fields)) {
64 64
 			if (!$fields instanceof HtmlFormFields) {
65
-				if (\is_array($fields) === false) {
65
+				if (\is_array($fields)===false) {
66 66
 					$fields=\func_get_args();
67 67
 					$end=\end($fields);
68 68
 					if (\is_string($end)) {
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
 						$label=NULL;
73 73
 				}
74 74
 				$this->_fields=\array_merge($this->_fields, $fields);
75
-				$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields);
75
+				$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields);
76 76
 			}
77 77
 			if (isset($label))
78 78
 				$fields=new HtmlFormField("", $fields, $label);
79 79
 		} else {
80
-			$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count());
80
+			$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count());
81 81
 		}
82 82
 		$this->addItem($fields);
83 83
 		return $fields;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 	public function addItem($item) {
87 87
 		$item=parent::addItem($item);
88
-		if (\is_subclass_of($item, HtmlFormField::class) === true) {
88
+		if (\is_subclass_of($item, HtmlFormField::class)===true) {
89 89
 			$this->_fields[]=$item;
90 90
 		}
91 91
 		return $item;
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 		return $this->addItem($field);
118 118
 	}
119 119
 
120
-	public function addFieldRule($index,$type,$prompt=NULL,$value=NULL){
120
+	public function addFieldRule($index, $type, $prompt=NULL, $value=NULL) {
121 121
 		$field=$this->getItem($index);
122
-		if(isset($field)){
123
-			$field->addRule($type,$prompt,$value);
122
+		if (isset($field)) {
123
+			$field->addRule($type, $prompt, $value);
124 124
 		}
125 125
 		return $this;
126 126
 	}
@@ -147,17 +147,17 @@  discard block
 block discarded – undo
147 147
 
148 148
 	public function run(JsUtils $js) {
149 149
 		$compo=NULL;
150
-		foreach ($this->_fields as $field){
150
+		foreach ($this->_fields as $field) {
151 151
 			$validation=$field->getValidation();
152
-			if(isset($validation)){
153
-				if(isset($compo)===false){
152
+			if (isset($validation)) {
153
+				if (isset($compo)===false) {
154 154
 					$compo=$js->semantic()->form("#".$this->identifier);
155 155
 				}
156 156
 				$validation->setIdentifier($field->getField()->getIdentifier());
157 157
 				$compo->addFieldValidation($validation);
158 158
 			}
159 159
 		}
160
-		if(isset($compo)===false){
160
+		if (isset($compo)===false) {
161 161
 			return parent::run($js);
162 162
 		}
163 163
 		$compo->addParams($this->_validationParams);
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		return $this->addToProperty("class", "loading");
171 171
 	}
172 172
 
173
-	public function addErrorMessage(){
173
+	public function addErrorMessage() {
174 174
 		return $this->addContent((new HtmlMessage(""))->setError());
175 175
 	}
176 176
 
Please login to merge, or discard this patch.
Ajax/Semantic.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 use function Composer\Autoload\includeFile;
22 22
 
23 23
 class Semantic extends BaseGui {
24
-	use SemanticComponentsTrait,SemanticHtmlElementsTrait,SemanticHtmlCollectionsTrait,
25
-	SemanticHtmlModulesTrait,SemanticHtmlViewsTrait;
24
+	use SemanticComponentsTrait, SemanticHtmlElementsTrait, SemanticHtmlCollectionsTrait,
25
+	SemanticHtmlModulesTrait, SemanticHtmlViewsTrait;
26 26
 
27 27
 	private $language;
28 28
 
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
 		return $this->addHtmlComponent(new HtmlSticky($identifier, $content));
111 111
 	}
112 112
 
113
-	public function setLanguage($language){
114
-		if($language!==$this->language){
113
+	public function setLanguage($language) {
114
+		if ($language!==$this->language) {
115 115
 			$file=\realpath(dirname(__FILE__)."/semantic/components/validation/languages/".$language.".js");
116
-			if(\file_exists($file)){
116
+			if (\file_exists($file)) {
117 117
 				$script=\file_get_contents($file);
118
-				$this->js->exec($script,true);
118
+				$this->js->exec($script, true);
119 119
 				$this->language=$language;
120 120
 			}
121 121
 		}
Please login to merge, or discard this patch.