Skip to content

Commit

Permalink
Update CreateWebService.php
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Jan 16, 2024
1 parent 16e63f5 commit dceb8c7
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions webfiori/framework/cli/helpers/CreateWebService.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ private function addParamsToService() {
$paramObj->setIsOptional($this->confirm('Is this parameter optional?', true));
if ($paramObj->getType() == ParamType::STRING || $paramObj->getType() == ParamType::URL || $paramObj->getType() == ParamType::EMAIL) {
$paramObj->setIsEmptyStringAllowed($this->confirm('Are empty values allowed?', false));
$paramObj->setMinLength($this->getCommand()->readInteger('Minimum length:'));
$paramObj->setMaxLength($this->getCommand()->readInteger('Maximum length:'));
$this->setMinAndMaxLength($paramObj);
}
if ($paramObj->getType() == ParamType::INT || $paramObj->getType() == ParamType::DOUBLE) {
$this->setMinAndMax($paramObj);
Expand All @@ -88,6 +87,26 @@ private function addParamsToService() {
$addMore = $this->confirm('Would you like to add another parameter?', false);
} while ($addMore);
}
private function setMinAndMaxLength(RequestParameter $param) {
$setMinMax = $this->confirm('Would you like to set minimum and maximum length?', false);

if (!$setMinMax) {
return;
}
$isValid = false;

Check warning on line 96 in webfiori/framework/cli/helpers/CreateWebService.php

View check run for this annotation

Codecov / codecov/patch

webfiori/framework/cli/helpers/CreateWebService.php#L96

Added line #L96 was not covered by tests

while (!$isValid) {
$min = $this->getCommand()->readInteger('Minimum length:');
$max = $this->getCommand()->readInteger('Maximum length:');
if ($min < $max) {
$param->setMinLength($min);
$param->setMaxLength($max);
$isValid = true;
} else {
$this->error('Minimum and maximum should not overlap.');

Check warning on line 106 in webfiori/framework/cli/helpers/CreateWebService.php

View check run for this annotation

Codecov / codecov/patch

webfiori/framework/cli/helpers/CreateWebService.php#L98-L106

Added lines #L98 - L106 were not covered by tests
}
}
}
private function setMinAndMax(RequestParameter $param) {
$setMinMax = $this->confirm('Would you like to set minimum and maximum limites?', false);

Expand Down

0 comments on commit dceb8c7

Please sign in to comment.