@@ -76,31 +76,39 @@ class FieldBuilder {
7676 * @return static $this
7777 */
7878 public function setName (string $ name ): FieldBuilder {
79+ if (isset ($ this ->name )) {
80+ throw new \RuntimeException ('Field name is already specified ' );
81+ }
82+
7983 $ this ->name = $ name ;
8084 return $ this ;
8185 }
8286
8387 /**
84- * Sets field editable or not
85- *
86- * @param bool $editable Is field editable
88+ * Sets field editable
8789 *
8890 * @return static $this
8991 */
90- public function setEditable (bool $ editable ): FieldBuilder {
91- $ this ->editable = $ editable ;
92+ public function setEditable (): FieldBuilder {
93+ if ($ this ->editable ) {
94+ throw new \RuntimeException ('Field is already setted editable ' );
95+ }
96+
97+ $ this ->editable = true ;
9298 return $ this ;
9399 }
94100
95101 /**
96- * Sets field direct or not
97- *
98- * @param bool $editable Is field direct
102+ * Sets field direct
99103 *
100104 * @return static $this
101105 */
102- public function setDirect (bool $ direct ): FieldBuilder {
103- $ this ->direct = $ direct ;
106+ public function setDirect (): FieldBuilder {
107+ if ($ this ->direct ) {
108+ throw new \RuntimeException ('Field is already setted direct ' );
109+ }
110+
111+ $ this ->direct = true ;
104112 return $ this ;
105113 }
106114
@@ -117,13 +125,15 @@ public function setType(string $type): FieldBuilder {
117125 }
118126
119127 /**
120- * Sets filter default value
121- *
122- * @param string $filterDefault New filter default field value
128+ * Sets field not filters default value
123129 *
124130 * @return static $this
125131 */
126- public function setFilterDefault (string $ filterDefault ): FieldBuilder {
132+ public function setNotFilterDefault (): FieldBuilder {
133+ if (!$ this ->filterDefault ) {
134+ throw new \RuntimeException ('Field is already setted not filters default ' );
135+ }
136+
127137 $ this ->filterDefault = $ filterDefault ;
128138 return $ this ;
129139 }
@@ -137,7 +147,7 @@ public function setFilterDefault(string $filterDefault): FieldBuilder {
137147 */
138148 public function setDefault (string $ default ): FieldBuilder {
139149 if (isset ($ this ->default )) {
140- throw new \Exception ('Default value is already setted ' );
150+ throw new \RuntimeException ('Default value is already specified ' );
141151 }
142152
143153 $ this ->default = $ default ;
@@ -152,10 +162,12 @@ public function setDefault(string $default): FieldBuilder {
152162 * @return static $this
153163 */
154164 public function addValidator (string $ validator ): FieldBuilder {
155- if (! in_array ($ validator , $ this ->validators )) {
156- $ this -> validators [] = $ validator ;
165+ if (in_array ($ validator , $ this ->validators )) {
166+ throw new \ RuntimeException ( " Validator \" $ validator\" is already added " ) ;
157167 }
158168
169+ $ this ->validators [] = $ validator ;
170+
159171 return $ this ;
160172 }
161173
0 commit comments