File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -358,23 +358,27 @@ public function match(string $name): array
358358 * helper methods
359359 **********************************************************/
360360
361+ /**
362+ * command name pattern.
363+ * old: '/^[a-z][\w-]*:?([a-z][\w-]+)?$/'
364+ */
365+ public const NAME_PATTERN = '/^[a-z][\w:-]*$/ ' ;
366+
361367 /**
362368 * @param string $name
363369 *
364370 * @throws InvalidArgumentException
365371 */
366372 protected function validateName (string $ name ): void
367373 {
368- // '/^[a-z][\w-]*:?([a-z][\w-]+)?$/'
369- $ pattern = '/^[a-z][\w:-]+$/ ' ;
370-
374+ $ pattern = self ::NAME_PATTERN ;
371375 if (1 !== preg_match ($ pattern , $ name )) {
372376 throw new InvalidArgumentException ("The command name ' $ name' is must match: $ pattern " );
373377 }
374378
375- // cannot be override . like: help, version
379+ // cannot be overridden . like: help, version
376380 if ($ this ->isBlocked ($ name )) {
377- throw new InvalidArgumentException ("The command name '$ name' is not allowed. It is a built in command. " );
381+ throw new InvalidArgumentException ("Command name '$ name' is not allowed. It is a built in command. " );
378382 }
379383 }
380384
You can’t perform that action at this time.
0 commit comments