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

refactor: Move description to trait #482

Merged
merged 1 commit into from
Feb 20, 2024
Merged
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
17 changes: 3 additions & 14 deletions src/PhpPact/Consumer/Model/Interaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,20 @@

namespace PhpPact\Consumer\Model;

use PhpPact\Consumer\Model\Interaction\DescriptionTrait;

/**
* Request/Response Pair to be posted to the Mock Server for PACT tests.
*/
class Interaction
{
use ProviderStates;

private string $description;
use DescriptionTrait;

private ConsumerRequest $request;

private ProviderResponse $response;

public function getDescription(): string
{
return $this->description;
}

public function setDescription(string $description): self
{
$this->description = $description;

return $this;
}

public function getRequest(): ConsumerRequest
{
return $this->request;
Expand Down
20 changes: 20 additions & 0 deletions src/PhpPact/Consumer/Model/Interaction/DescriptionTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace PhpPact\Consumer\Model\Interaction;

trait DescriptionTrait
{
private string $description;

public function getDescription(): string
{
return $this->description;
}

public function setDescription(string $description): self
{
$this->description = $description;

return $this;
}
}
16 changes: 2 additions & 14 deletions src/PhpPact/Consumer/Model/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
use PhpPact\Consumer\Model\Body\Binary;
use PhpPact\Consumer\Model\Body\Multipart;
use PhpPact\Consumer\Model\Body\Text;
use PhpPact\Consumer\Model\Interaction\DescriptionTrait;

/**
* Message metadata and contents to be posted to the Mock Server for PACT tests.
*/
class Message
{
use ProviderStates;

private string $description;
use DescriptionTrait;

/**
* @var array<string, string>
Expand All @@ -25,18 +25,6 @@ class Message

private Text|Binary|null $contents = null;

public function getDescription(): string
{
return $this->description;
}

public function setDescription(string $description): self
{
$this->description = $description;

return $this;
}

/**
* @return array<string, string>
*/
Expand Down
Loading