diff --git a/src/PhpPact/Consumer/Matcher/Matchers/MaxType.php b/src/PhpPact/Consumer/Matcher/Matchers/MaxType.php new file mode 100644 index 00000000..098c80b9 --- /dev/null +++ b/src/PhpPact/Consumer/Matcher/Matchers/MaxType.php @@ -0,0 +1,38 @@ +$values + */ + public function __construct( + private array $values, + private int $max, + ) { + } + + /** + * @return array + */ + public function jsonSerialize(): array + { + return [ + 'pact:matcher:type' => $this->getType(), + 'max' => $this->max, + 'value' => array_values($this->values), + ]; + } + + public function getType(): string + { + return 'type'; + } +} diff --git a/tests/PhpPact/Consumer/Matcher/Matchers/MaxTypeTest.php b/tests/PhpPact/Consumer/Matcher/Matchers/MaxTypeTest.php new file mode 100644 index 00000000..2c034c90 --- /dev/null +++ b/tests/PhpPact/Consumer/Matcher/Matchers/MaxTypeTest.php @@ -0,0 +1,21 @@ +assertSame( + '{"pact:matcher:type":"type","max":3,"value":["string value"]}', + json_encode($array) + ); + } +}