Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
woutse committed Jan 25, 2025
1 parent 8827b78 commit 83e1e75
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/Request/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ public function __construct(array $options = [])
$this->setFormat($this->getOption('format'));
}

if (true === $this->hasOption('headers')
&& true === is_array($this->getOption('headers'))
) {
if (true === $this->hasOption('headers') && true === is_array($this->getOption('headers'))) {
$this->setHeaders($this->getOption('headers'));
}

Expand All @@ -138,7 +136,7 @@ public function getParams(): array
}

/**
* @param string|int $name
* @param string|integer $name
*
* @return mixed|null
*/
Expand All @@ -153,7 +151,7 @@ public function getParam($name)
/**
* @param string|integer $name
*
* @return bool
* @return boolean
*/
public function hasParam($name): bool
{
Expand Down Expand Up @@ -188,7 +186,7 @@ public function setParams(array $params): self
$optionalParams = [];
foreach ($this->getOptionalParams() as $paramName => $paramDefinition) {
# If optional paramater is provided...
if(isset($params[$paramName])) {
if (isset($params[$paramName])) {
if (true === is_string($paramDefinition) && '' !== $paramDefinition && 1 !== preg_match("/^{$paramDefinition}$/", $this->getParam($paramName))) {
throw new InvalidArgumentException(sprintf('Optional param %s is not valid. It must match "%s"', $paramName, $paramDefinition));
}
Expand All @@ -204,7 +202,7 @@ public function setParams(array $params): self
}

/**
* @inheritDoc
* @return string
*/
public function getUri(): string
{
Expand All @@ -223,7 +221,7 @@ public function setUri(string $uri): self
}

/**
* @inheritDoc
* @return string
*/
public function getMethod(): string
{
Expand Down Expand Up @@ -346,16 +344,15 @@ public function getBody(): string
*
* @return AbstractRequest
*/
public function setBody($body): self
public function setBody(mixed $body): self
{
$this->body = $body;
return $this;
}

/**
* @inheritDoc
*
* @return AbstractRequest
* @param Client $client
* @return $this
*/
public function applyClient(Client $client): self
{
Expand Down Expand Up @@ -433,7 +430,7 @@ public function addFilter(FilterInterface $filter): self
*
* @return string
*/
private function encodeBody($body): string
private function encodeBody(mixed $body): string
{
$encoder = new JsonEncoder();
$contentTypeHeader = 'application/json';
Expand Down Expand Up @@ -616,7 +613,7 @@ protected function flattenErrors(array $errors, string $context = ''): array
*
* @return void
*/
protected function validateBody($body): void
protected function validateBody(mixed $body): void
{
if (true === is_string($body)) {
return;
Expand Down

0 comments on commit 83e1e75

Please sign in to comment.