Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update brandembassy/datetime (3.0) #43

Open
wants to merge 1 commit into
base: 5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"require": {
"php": ">=7.2",
"brandembassy/datetime": "^2.2",
"brandembassy/datetime": "^3.0",
"nette/di": "^3.0",
"nette/neon": "^3.0",
"nette/utils": "^3.0",
Expand Down
18 changes: 9 additions & 9 deletions src/Request/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/**
* @method string[]|string[][] getQueryParams()
* @method string|string[]|null getQueryParam(string $key, ?string $default = null)
* @method string|string[]|null getQueryParam(string $name, ?string $default = null)
*/
final class Request extends SlimRequest implements RequestInterface
{
Expand Down Expand Up @@ -117,9 +117,9 @@ public function hasField(string $fieldName): bool
/**
* @return string|string[]|null
*/
public function findQueryParam(string $key, ?string $default = null)
public function findQueryParam(string $name, ?string $default = null)
{
return $this->getQueryParam($key) ?? $default;
return $this->getQueryParam($name) ?? $default;
}


Expand All @@ -128,21 +128,21 @@ public function findQueryParam(string $key, ?string $default = null)
*
* @throws QueryParamMissingException
*/
public function getQueryParamStrict(string $key)
public function getQueryParamStrict(string $name)
{
$value = $this->findQueryParam($key);
$value = $this->findQueryParam($name);

if ($value !== null) {
return $value;
}

throw QueryParamMissingException::create($key);
throw QueryParamMissingException::create($name);
}


public function hasQueryParam(string $key): bool
public function hasQueryParam(string $name): bool
{
return array_key_exists($key, $this->getQueryParams());
return array_key_exists($name, $this->getQueryParams());
}


Expand All @@ -155,7 +155,7 @@ public function getDateTimeQueryParam(string $field, string $format = DateTime::
$datetimeParam = $this->getQueryParamStrict($field);
assert(is_string($datetimeParam));

return DateTimeFromString::create($format, $datetimeParam);
return DateTimeFromString::createFromFormat($format, $datetimeParam);
}


Expand Down
10 changes: 5 additions & 5 deletions src/Request/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public function hasField(string $fieldName): bool;
/**
* @return string|string[]|null
*/
public function findQueryParam(string $key, ?string $default = null);
public function findQueryParam(string $name, ?string $default = null);


/**
* @return string|string[]
*
* @throws QueryParamMissingException
*/
public function getQueryParamStrict(string $key);
public function getQueryParamStrict(string $name);


public function hasAttribute(string $name): bool;
Expand All @@ -80,10 +80,10 @@ public function findAttribute(string $name, $default = null);
public function getAttributeStrict(string $name);


public function hasQueryParam(string $key): bool;
public function hasQueryParam(string $name): bool;


public function getDateTimeQueryParam(string $key): DateTimeImmutable;
public function getDateTimeQueryParam(string $name): DateTimeImmutable;


public function isHtml(): bool;
Expand All @@ -109,5 +109,5 @@ public function getAttribute($name, $default = null);
*
* @return mixed
*/
public function getQueryParam(string $key, $default = null);
public function getQueryParam(string $name, $default = null);
}