Skip to content

Commit

Permalink
Remove jsonSerialize methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed Mar 15, 2023
1 parent d1068dc commit 814db59
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 96 deletions.
30 changes: 1 addition & 29 deletions src/PhpPact/Consumer/Model/ConsumerRequest.php
Expand Up @@ -6,7 +6,7 @@
* Request initiated by the consumer.
* Class ConsumerRequest.
*/
class ConsumerRequest implements \JsonSerializable
class ConsumerRequest
{
/**
* @var string
Expand Down Expand Up @@ -191,32 +191,4 @@ private function addQueryParameterValue(string $key, string $value): void
{
$this->query[$key][] = $value;
}

/**
* {@inheritdoc}
*/
public function jsonSerialize(): array
{
$results = [];

$results['method'] = $this->getMethod();

if ($this->getHeaders() !== null) {
$results['headers'] = $this->getHeaders();
}

if ($this->getPath() !== null) {
$results['path'] = $this->getPath();
}

if ($this->getBody() !== null) {
$results['body'] = $this->getBody();
}

if ($this->getQuery() !== null) {
$results['query'] = $this->getQuery();
}

return $results;
}
}
23 changes: 1 addition & 22 deletions src/PhpPact/Consumer/Model/Interaction.php
Expand Up @@ -6,7 +6,7 @@
* Request/Response Pair to be posted to the Ruby Standalone Mock Server for PACT tests.
* Class Interaction.
*/
class Interaction implements \JsonSerializable
class Interaction
{
/**
* @var int
Expand Down Expand Up @@ -132,25 +132,4 @@ public function setResponse(ProviderResponse $response): self

return $this;
}

/**
* {@inheritdoc}
*/
public function jsonSerialize(): array
{
if ($this->getProviderState()) {
return [
'description' => $this->getDescription(),
'providerState' => $this->getProviderState(),
'request' => $this->getRequest(),
'response' => $this->getResponse(),
];
}

return [
'description' => $this->getDescription(),
'request' => $this->getRequest(),
'response' => $this->getResponse(),
];
}
}
25 changes: 1 addition & 24 deletions src/PhpPact/Consumer/Model/Message.php
Expand Up @@ -6,7 +6,7 @@
* Request/Response Pair to be posted to the Ruby Standalone Mock Server for PACT tests.
* Class Message.
*/
class Message implements \JsonSerializable
class Message
{
/**
* @var int
Expand Down Expand Up @@ -162,27 +162,4 @@ public function setContents(mixed $contents): self

return $this;
}

/**
* {@inheritdoc}
*/
public function jsonSerialize(): array
{
$out = [];
$out['description'] = $this->getDescription();

if (\count($this->providerStates) > 0) {
$out['providerStates'] = $this->getProviderStates();
}

if ($this->metadata) {
$out['metadata'] = $this->getMetadata();
}

if ($this->contents) {
$out['contents'] = $this->getContents();
}

return $out;
}
}
22 changes: 1 addition & 21 deletions src/PhpPact/Consumer/Model/ProviderResponse.php
Expand Up @@ -6,7 +6,7 @@
* Response expectation that would be in response to a Consumer request from the Provider.
* Class ProviderResponse.
*/
class ProviderResponse implements \JsonSerializable
class ProviderResponse
{
/**
* @var int
Expand Down Expand Up @@ -115,24 +115,4 @@ public function setBody(mixed $body): self

return $this;
}

/**
* {@inheritdoc}
*/
public function jsonSerialize(): array
{
$results = [
'status' => $this->getStatus(),
];

if ($this->getHeaders() !== null) {
$results['headers'] = $this->getHeaders();
}

if ($this->getBody() !== null) {
$results['body'] = $this->getBody();
}

return $results;
}
}

0 comments on commit 814db59

Please sign in to comment.