File tree Expand file tree Collapse file tree 3 files changed +47
-5
lines changed Expand file tree Collapse file tree 3 files changed +47
-5
lines changed Original file line number Diff line number Diff line change 9
9
10
10
namespace Toolkit \PFlag \Contract ;
11
11
12
+ use Toolkit \PFlag \FlagsParser ;
13
+
12
14
/**
13
15
* interface ParserInterface
14
16
*/
@@ -127,6 +129,14 @@ public function hasInputOpt(string $name): bool;
127
129
*/
128
130
public function getOpt (string $ name , $ default = null );
129
131
132
+ /**
133
+ * @param string $name
134
+ *
135
+ * @return array
136
+ * @see FlagsParser::DEFINE_ITEM
137
+ */
138
+ public function getOptDefine (string $ name ): array ;
139
+
130
140
/**
131
141
* Set option value, will format and validate value.
132
142
*
@@ -173,6 +183,7 @@ public function getArgIndex($nameOrIndex): int;
173
183
* @param string|int $nameOrIndex
174
184
*
175
185
* @return array
186
+ * @see FlagsParser::DEFINE_ITEM
176
187
*/
177
188
public function getArgDefine ($ nameOrIndex ): array ;
178
189
@@ -231,12 +242,13 @@ public function getArgsHelpData(): array;
231
242
*/
232
243
public function getOptsHelpData (): array ;
233
244
245
+ public function lock (): void ;
246
+
247
+ public function unlock (): void ;
248
+
234
249
/**
235
250
* @return bool
236
251
*/
237
252
public function isLocked (): bool ;
238
253
239
- public function lock (): void ;
240
-
241
- public function unlock (): void ;
242
254
}
Original file line number Diff line number Diff line change @@ -867,7 +867,7 @@ public function hasOpt(string $name): bool
867
867
*/
868
868
public function getOpt (string $ name , $ default = null )
869
869
{
870
- $ opt = $ this ->getDefinedOption ($ name );
870
+ $ opt = $ this ->getOption ($ name );
871
871
if (!$ opt ) { // not exist
872
872
throw new FlagException ("flag option ' $ name' is undefined " );
873
873
}
@@ -899,7 +899,7 @@ public function setOpt(string $name, $value): void
899
899
*/
900
900
public function setTrustedOpt (string $ name , $ value ): void
901
901
{
902
- $ opt = $ this ->getDefinedOption ($ name );
902
+ $ opt = $ this ->getOption ($ name );
903
903
if (!$ opt ) { // not exist option
904
904
throw new FlagException ("flag option ' $ name' is undefined " );
905
905
}
@@ -917,6 +917,21 @@ public function getOption(string $name): ?Option
917
917
return $ this ->options [$ name ] ?? null ;
918
918
}
919
919
920
+ /**
921
+ * @param string $name
922
+ *
923
+ * @return array
924
+ */
925
+ public function getOptDefine (string $ name ): array
926
+ {
927
+ $ opt = $ this ->getOption ($ name );
928
+ if (!$ opt ) { // not exist option
929
+ throw new FlagException ("flag option ' $ name' is undefined " );
930
+ }
931
+
932
+ return $ opt ->toArray ();
933
+ }
934
+
920
935
/**
921
936
* @param string $name
922
937
*
Original file line number Diff line number Diff line change @@ -813,6 +813,21 @@ public function getOpt(string $name, $default = null)
813
813
return $ default ?? FlagType::getDefault ($ define ['type ' ]);
814
814
}
815
815
816
+ /**
817
+ * @param string $name
818
+ *
819
+ * @return array
820
+ */
821
+ public function getOptDefine (string $ name ): array
822
+ {
823
+ $ define = $ this ->optDefines [$ name ] ?? [];
824
+ if (!$ define ) { // not exist
825
+ throw new FlagException ("flag option ' $ name' is undefined " );
826
+ }
827
+
828
+ return $ define ;
829
+ }
830
+
816
831
/**
817
832
* @param string $name
818
833
* @param mixed $value
You can’t perform that action at this time.
0 commit comments