-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #598 from tienvx/extract-traits
refactor: Extract traits
- Loading branch information
Showing
4 changed files
with
50 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/PhpPact/Consumer/Matcher/Trait/FormatterAwareTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace PhpPact\Consumer\Matcher\Trait; | ||
|
||
use PhpPact\Consumer\Matcher\Formatters\ValueOptionalFormatter; | ||
use PhpPact\Consumer\Matcher\Model\FormatterInterface; | ||
|
||
trait FormatterAwareTrait | ||
{ | ||
private FormatterInterface $formatter; | ||
|
||
public function __construct() | ||
{ | ||
$this->formatter = new ValueOptionalFormatter(); | ||
} | ||
|
||
public function setFormatter(FormatterInterface $formatter): void | ||
{ | ||
$this->formatter = $formatter; | ||
} | ||
|
||
public function getFormatter(): FormatterInterface | ||
{ | ||
return $this->formatter; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/PhpPact/Consumer/Matcher/Trait/GeneratorAwareTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace PhpPact\Consumer\Matcher\Trait; | ||
|
||
use PhpPact\Consumer\Matcher\Model\GeneratorInterface; | ||
|
||
trait GeneratorAwareTrait | ||
{ | ||
private ?GeneratorInterface $generator = null; | ||
|
||
public function setGenerator(?GeneratorInterface $generator): void | ||
{ | ||
$this->generator = $generator; | ||
} | ||
|
||
public function getGenerator(): ?GeneratorInterface | ||
{ | ||
return $this->generator; | ||
} | ||
} |