From d9b5b471b4cf70126a36ed4fd954f8e99db3e98f Mon Sep 17 00:00:00 2001 From: "tien.xuan.vo" Date: Tue, 26 Dec 2023 23:59:18 +0700 Subject: [PATCH] refactor: Move xml to core --- composer.json | 1 - .../tests/Service/HttpClientServiceTest.php | 2 +- .../Xml/Model/Builder/ElementTrait.php | 54 +++ .../Xml/Model/Builder/GeneratorTrait.php | 21 ++ .../Xml/Model/Builder/MatcherTrait.php | 21 ++ src/PhpPact/Xml/Model/Builder/TextTrait.php | 35 ++ src/PhpPact/Xml/Model/Matcher/Generator.php | 43 +++ src/PhpPact/Xml/Model/Matcher/Matcher.php | 43 +++ src/PhpPact/Xml/XmlBuilder.php | 32 ++ src/PhpPact/Xml/XmlElement.php | 113 ++++++ src/PhpPact/Xml/XmlText.php | 71 ++++ .../PhpPact/Xml/XmlBuilderIntegrationTest.php | 336 ++++++++++++++++++ tests/PhpPact/Xml/XmlBuilderTest.php | 110 ++++++ tests/PhpPact/Xml/XmlElementTest.php | 86 +++++ tests/PhpPact/Xml/XmlTextTest.php | 73 ++++ 15 files changed, 1039 insertions(+), 2 deletions(-) create mode 100644 src/PhpPact/Xml/Model/Builder/ElementTrait.php create mode 100644 src/PhpPact/Xml/Model/Builder/GeneratorTrait.php create mode 100644 src/PhpPact/Xml/Model/Builder/MatcherTrait.php create mode 100644 src/PhpPact/Xml/Model/Builder/TextTrait.php create mode 100644 src/PhpPact/Xml/Model/Matcher/Generator.php create mode 100644 src/PhpPact/Xml/Model/Matcher/Matcher.php create mode 100644 src/PhpPact/Xml/XmlBuilder.php create mode 100644 src/PhpPact/Xml/XmlElement.php create mode 100644 src/PhpPact/Xml/XmlText.php create mode 100644 tests/PhpPact/Xml/XmlBuilderIntegrationTest.php create mode 100644 tests/PhpPact/Xml/XmlBuilderTest.php create mode 100644 tests/PhpPact/Xml/XmlElementTest.php create mode 100644 tests/PhpPact/Xml/XmlTextTest.php diff --git a/composer.json b/composer.json index f53a4b8f..577c5b37 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,6 @@ "phpstan/phpstan": "^1.9", "phpunit/phpunit": ">=8.5.23 <10", "guzzlehttp/guzzle": "^7.8", - "tienvx/pact-php-xml": "^0.1", "behat/behat": "^3.13", "galbar/jsonpath": "^3.0", "ramsey/uuid": "^4.7" diff --git a/example/xml/consumer/tests/Service/HttpClientServiceTest.php b/example/xml/consumer/tests/Service/HttpClientServiceTest.php index c4e31582..1ed429e7 100644 --- a/example/xml/consumer/tests/Service/HttpClientServiceTest.php +++ b/example/xml/consumer/tests/Service/HttpClientServiceTest.php @@ -2,7 +2,7 @@ namespace XmlConsumer\Tests\Service; -use Tienvx\PactPhpXml\XmlBuilder; +use PhpPact\Xml\XmlBuilder; use XmlConsumer\Service\HttpClientService; use PhpPact\Consumer\InteractionBuilder; use PhpPact\Consumer\Model\ConsumerRequest; diff --git a/src/PhpPact/Xml/Model/Builder/ElementTrait.php b/src/PhpPact/Xml/Model/Builder/ElementTrait.php new file mode 100644 index 00000000..cffc7fc0 --- /dev/null +++ b/src/PhpPact/Xml/Model/Builder/ElementTrait.php @@ -0,0 +1,54 @@ +root = new XmlElement(...$options); + } + + public function add(callable ...$options): callable + { + return fn (XmlElement $element) => $element->addChild(new XmlElement(...$options)); + } + + public function name(string $name): callable + { + return fn (XmlElement $element) => $element->setName($name); + } + + public function text(callable ...$options): callable + { + return fn (XmlElement $element) => $element->setText(new XmlText(...$options)); + } + + public function attribute(string $name, mixed $value): callable + { + return fn (XmlElement $element) => $element->addAttribute($name, $value); + } + + public function eachLike(int $min = 1, ?int $max = null, int $examples = 1): callable + { + return function (XmlElement $element) use ($min, $max, $examples): void { + $options = [ + 'min' => $min, + 'examples' => $examples, + ]; + if (isset($max)) { + $options['max'] = $max; + } + $element->setMatcher(new Matcher( + fn (Matcher $matcher) => $matcher->setType('type'), + fn (Matcher $matcher) => $matcher->setOptions($options), + )); + }; + } +} diff --git a/src/PhpPact/Xml/Model/Builder/GeneratorTrait.php b/src/PhpPact/Xml/Model/Builder/GeneratorTrait.php new file mode 100644 index 00000000..32a5be4e --- /dev/null +++ b/src/PhpPact/Xml/Model/Builder/GeneratorTrait.php @@ -0,0 +1,21 @@ + $generator->setType($type); + } + + /** + * @param array $options + */ + public function generatorOptions(array $options): callable + { + return fn (Generator $generator) => $generator->setOptions($options); + } +} diff --git a/src/PhpPact/Xml/Model/Builder/MatcherTrait.php b/src/PhpPact/Xml/Model/Builder/MatcherTrait.php new file mode 100644 index 00000000..4e38d0e8 --- /dev/null +++ b/src/PhpPact/Xml/Model/Builder/MatcherTrait.php @@ -0,0 +1,21 @@ + $matcher->setType($type); + } + + /** + * @param array $options + */ + public function matcherOptions(array $options): callable + { + return fn (Matcher $matcher) => $matcher->setOptions($options); + } +} diff --git a/src/PhpPact/Xml/Model/Builder/TextTrait.php b/src/PhpPact/Xml/Model/Builder/TextTrait.php new file mode 100644 index 00000000..bd785fc6 --- /dev/null +++ b/src/PhpPact/Xml/Model/Builder/TextTrait.php @@ -0,0 +1,35 @@ + $text->setContent($content); + } + + public function matcher(callable ...$options): callable + { + return fn (XmlText $text) => $text->setMatcher(new Matcher(...$options)); + } + + public function generator(callable ...$options): callable + { + return fn (XmlText $text) => $text->setGenerator(new Generator(...$options)); + } + + public function contentLike(string|int|float $content): callable + { + return function (XmlText $text) use ($content): void { + $text->setContent($content); + $text->setMatcher(new Matcher( + fn (Matcher $matcher) => $matcher->setType('type') + )); + }; + } +} diff --git a/src/PhpPact/Xml/Model/Matcher/Generator.php b/src/PhpPact/Xml/Model/Matcher/Generator.php new file mode 100644 index 00000000..5419223f --- /dev/null +++ b/src/PhpPact/Xml/Model/Matcher/Generator.php @@ -0,0 +1,43 @@ + + */ + protected array $options = []; + + public function __construct(callable ...$options) + { + array_walk($options, fn (callable $option) => $option($this)); + } + + public function setType(string $type): self + { + $this->type = $type; + + return $this; + } + + /** + * @param array $options + */ + public function setOptions(array $options): self + { + $this->options = $options; + + return $this; + } + + /** + * @return array + */ + public function getArray(): array + { + return ['pact:generator:type' => $this->type] + $this->options; + } +} diff --git a/src/PhpPact/Xml/Model/Matcher/Matcher.php b/src/PhpPact/Xml/Model/Matcher/Matcher.php new file mode 100644 index 00000000..4e7e3a4b --- /dev/null +++ b/src/PhpPact/Xml/Model/Matcher/Matcher.php @@ -0,0 +1,43 @@ + + */ + protected array $options = []; + + public function __construct(callable ...$options) + { + array_walk($options, fn (callable $option) => $option($this)); + } + + public function setType(string $type): self + { + $this->type = $type; + + return $this; + } + + /** + * @param array $options + */ + public function setOptions(array $options): self + { + $this->options = $options; + + return $this; + } + + /** + * @return array + */ + public function getArray(): array + { + return ['pact:matcher:type' => $this->type] + $this->options; + } +} diff --git a/src/PhpPact/Xml/XmlBuilder.php b/src/PhpPact/Xml/XmlBuilder.php new file mode 100644 index 00000000..76260fda --- /dev/null +++ b/src/PhpPact/Xml/XmlBuilder.php @@ -0,0 +1,32 @@ + + */ + public function getArray(): array + { + return [ + 'version' => $this->version, + 'charset' => $this->charset, + 'root' => $this->root->getArray(), + ]; + } +} diff --git a/src/PhpPact/Xml/XmlElement.php b/src/PhpPact/Xml/XmlElement.php new file mode 100644 index 00000000..31eb9c00 --- /dev/null +++ b/src/PhpPact/Xml/XmlElement.php @@ -0,0 +1,113 @@ + + */ + private array $attributes = []; + + private ?XmlText $text = null; + + private ?Matcher $matcher = null; + + private ?Generator $generator = null; + + public function __construct(callable ...$options) + { + array_walk($options, fn (callable $option) => $option($this)); + } + + public function setName(string $name): self + { + $this->name = preg_replace('/(^[0-9]+|[^a-zA-Z0-9\-\_\:]+)/', '', $name); + + return $this; + } + + public function addChild(self $child): self + { + $this->children[] = $child; + + return $this; + } + + public function setText(?XmlText $text): self + { + $this->text = $text; + + return $this; + } + + public function setMatcher(?Matcher $matcher): self + { + $this->matcher = $matcher; + + return $this; + } + + public function setGenerator(?Generator $generator): self + { + $this->generator = $generator; + + return $this; + } + + public function addAttribute(string $name, mixed $value): self + { + $this->attributes[$name] = $value; + + return $this; + } + + /** + * @return array + */ + public function getArray(): array + { + if ($this->matcher) { + $result = [ + 'value' => $this->getBaseArray(), + ]; + $result += $this->matcher->getArray(); + + if ($this->generator) { + $result += $this->generator->getArray(); + } + } else { + $result = $this->getBaseArray(); + } + + return $result; + } + + /** + * @return array + */ + private function getBaseArray(): array + { + $result = [ + 'name' => $this->name, + 'children' => array_map(fn (XmlElement $element) => $element->getArray(), $this->children), + 'attributes' => $this->attributes + ]; + + if ($this->text) { + $result['children'][] = $this->text->getArray(); + } + + return $result; + } +} diff --git a/src/PhpPact/Xml/XmlText.php b/src/PhpPact/Xml/XmlText.php new file mode 100644 index 00000000..435cfc12 --- /dev/null +++ b/src/PhpPact/Xml/XmlText.php @@ -0,0 +1,71 @@ + $option($this)); + } + + public function setContent(string|int|float $content): self + { + $this->content = $content; + + return $this; + } + + public function setMatcher(?Matcher $matcher): self + { + $this->matcher = $matcher; + + return $this; + } + + public function setGenerator(?Generator $generator): self + { + $this->generator = $generator; + + return $this; + } + + /** + * @return array + */ + public function getArray(): array + { + $result = $this->getBaseArray(); + + if ($this->matcher) { + $result['matcher'] = $this->matcher->getArray(); + } + + if ($this->generator) { + $generator = $this->generator->getArray(); + $result['pact:generator:type'] = $generator['pact:generator:type']; + $result['matcher'] += array_diff_key($generator, array_flip(['pact:generator:type'])); + } + + return $result; + } + + /** + * @return array + */ + private function getBaseArray(): array + { + return [ + 'content' => $this->content, + ]; + } +} diff --git a/tests/PhpPact/Xml/XmlBuilderIntegrationTest.php b/tests/PhpPact/Xml/XmlBuilderIntegrationTest.php new file mode 100644 index 00000000..58040aab --- /dev/null +++ b/tests/PhpPact/Xml/XmlBuilderIntegrationTest.php @@ -0,0 +1,336 @@ +builder = new XmlBuilder('1.0', 'UTF-8'); + $this->matcher = new Matcher(); + } + + public function testBuildWithMatchersOnAttributes(): void + { + $this->builder + ->root( + $this->builder->name('ns1:projects'), + $this->builder->attribute('id', '1234'), + $this->builder->attribute('xmlns:ns1', 'http://some.namespace/and/more/stuff'), + $this->builder->add( + $this->builder->eachLike(examples: 2), + $this->builder->name('ns1:project'), + $this->builder->attribute('id', $this->matcher->integerV3(1)), + $this->builder->attribute('type', 'activity'), + $this->builder->attribute('name', $this->matcher->string('Project 1')), + $this->builder->attribute('due', $this->matcher->datetime("yyyy-MM-dd'T'HH:mm:ss.SZ", '2016-02-11T09:46:56.023Z')), + $this->builder->add( + $this->builder->name('ns1:tasks'), + $this->builder->add( + $this->builder->eachLike(examples: 5), + $this->builder->name('ns1:task'), + $this->builder->attribute('id', $this->matcher->integerV3(1)), + $this->builder->attribute('name', $this->matcher->string('Task 1')), + $this->builder->attribute('done', $this->matcher->boolean()), + ), + ), + ), + ); + + $expectedArray = [ + 'version' => '1.0', + 'charset' => 'UTF-8', + 'root' => [ + 'name' => 'ns1:projects', + 'children' => [ + [ + 'value' => [ + 'name' => 'ns1:project', + 'children' => [ + [ + 'name' => 'ns1:tasks', + 'children' => [ + [ + 'value' => [ + 'name' => 'ns1:task', + 'children' => [], + 'attributes' => [ + 'id' => [ + 'pact:matcher:type' => + 'integer', + 'value' => 1, + ], + 'name' => [ + 'pact:matcher:type' => 'type', + 'value' => 'Task 1', + ], + 'done' => [ + 'pact:matcher:type' => 'type', + 'value' => true, + ], + ], + ], + 'pact:matcher:type' => 'type', + 'min' => 1, + 'examples' => 5, + ], + ], + 'attributes' => [], + ], + ], + 'attributes' => [ + 'id' => [ + 'pact:matcher:type' => 'integer', + 'value' => 1, + ], + 'type' => 'activity', + 'name' => [ + 'pact:matcher:type' => 'type', + 'value' => 'Project 1', + ], + 'due' => [ + 'pact:matcher:type' => 'datetime', + 'format' => "yyyy-MM-dd'T'HH:mm:ss.SZ", + 'value' => '2016-02-11T09:46:56.023Z', + ], + ], + ], + 'pact:matcher:type' => 'type', + 'min' => 1, + 'examples' => 2, + ], + ], + 'attributes' => [ + 'id' => '1234', + 'xmlns:ns1' => 'http://some.namespace/and/more/stuff', + ], + ], + ]; + + $this->assertSame(json_encode($expectedArray), json_encode($this->builder->getArray())); + } + + public function testBuildWithMatchersOnContent(): void + { + $this->builder + ->root( + $this->builder->name('movies'), + $this->builder->add( + $this->builder->eachLike(), + $this->builder->name('movie'), + $this->builder->add( + $this->builder->name('title'), + $this->builder->text( + $this->builder->contentLike('PHP: Behind the Parser'), + ), + ), + $this->builder->add( + $this->builder->name('characters'), + $this->builder->add( + $this->builder->eachLike(examples: 2), + $this->builder->name('character'), + $this->builder->add( + $this->builder->name('name'), + $this->builder->text( + $this->builder->contentLike('Ms. Coder'), + ), + ), + $this->builder->add( + $this->builder->name('actor'), + $this->builder->text( + $this->builder->contentLike('Onlivia Actora'), + ), + ), + ), + ), + $this->builder->add( + $this->builder->name('plot'), + $this->builder->text( + $this->builder->contentLike( + $plot = <<builder->add( + $this->builder->name('great-lines'), + $this->builder->add( + $this->builder->eachLike(), + $this->builder->name('line'), + $this->builder->text( + $this->builder->contentLike('PHP solves all my web problems'), + ), + ), + ), + $this->builder->add( + $this->builder->name('rating'), + $this->builder->attribute('type', 'thumbs'), + $this->builder->text( + $this->builder->contentLike(7), + ), + ), + $this->builder->add( + $this->builder->name('rating'), + $this->builder->attribute('type', 'stars'), + $this->builder->text( + $this->builder->contentLike(5), + ), + ), + ), + ); + + $expectedArray = [ + 'version' => '1.0', + 'charset' => 'UTF-8', + 'root' => [ + 'name' => 'movies', + 'children' => [ + [ + 'value' => [ + 'name' => 'movie', + 'children' => [ + [ + 'name' => 'title', + 'children' => [ + [ + 'content' => 'PHP: Behind the Parser', + 'matcher' => [ + 'pact:matcher:type' => 'type', + ], + ], + ], + 'attributes' => [], + ], + [ + 'name' => 'characters', + 'children' => [ + [ + 'value' => [ + 'name' => 'character', + 'children' => [ + [ + 'name' => 'name', + 'children' => [ + [ + 'content' => + 'Ms. Coder', + 'matcher' => [ + 'pact:matcher:type' => + 'type', + ], + ], + ], + 'attributes' => [], + ], + [ + 'name' => 'actor', + 'children' => [ + [ + 'content' => + 'Onlivia Actora', + 'matcher' => [ + 'pact:matcher:type' => + 'type', + ], + ], + ], + 'attributes' => [], + ], + ], + 'attributes' => [], + ], + 'pact:matcher:type' => 'type', + 'min' => 1, + 'examples' => 2, + ], + ], + 'attributes' => [], + ], + [ + 'name' => 'plot', + 'children' => [ + [ + 'content' => $plot, + 'matcher' => [ + 'pact:matcher:type' => 'type', + ], + ], + ], + 'attributes' => [], + ], + [ + 'name' => 'great-lines', + 'children' => [ + [ + 'value' => [ + 'name' => 'line', + 'children' => [ + [ + 'content' => + 'PHP solves all my web problems', + 'matcher' => [ + 'pact:matcher:type' => + 'type', + ], + ], + ], + 'attributes' => [], + ], + 'pact:matcher:type' => 'type', + 'min' => 1, + 'examples' => 1, + ], + ], + 'attributes' => [], + ], + [ + 'name' => 'rating', + 'children' => [ + [ + 'content' => 7, + 'matcher' => [ + 'pact:matcher:type' => 'type', + ], + ], + ], + 'attributes' => ['type' => 'thumbs'], + ], + [ + 'name' => 'rating', + 'children' => [ + [ + 'content' => 5, + 'matcher' => [ + 'pact:matcher:type' => 'type', + ], + ], + ], + 'attributes' => ['type' => 'stars'], + ], + ], + 'attributes' => [], + ], + 'pact:matcher:type' => 'type', + 'min' => 1, + 'examples' => 1, + ], + ], + 'attributes' => [], + ], + ]; + + $this->assertSame(json_encode($expectedArray), json_encode($this->builder->getArray())); + } +} diff --git a/tests/PhpPact/Xml/XmlBuilderTest.php b/tests/PhpPact/Xml/XmlBuilderTest.php new file mode 100644 index 00000000..ac8ad8cc --- /dev/null +++ b/tests/PhpPact/Xml/XmlBuilderTest.php @@ -0,0 +1,110 @@ +root( + $builder->name('Root'), + $builder->add( + $builder->name('First Child Second Element'), + $builder->text( + $builder->contentLike('Example Test') + ) + ), + $builder->add( + $builder->name('Second Parent'), + $builder->add( + $builder->name('Second child 1'), + $builder->attribute('myAttr', 'Attr Value') + ), + $builder->add( + $builder->name('Second child 2'), + $builder->text( + $builder->content('Test') + ) + ), + $builder->add( + $builder->name('Third Parent'), + $builder->add( + $builder->eachLike(), + $builder->name('Child') + ) + ), + ), + $builder->add( + $builder->name('First Child Third Element'), + ), + ) + ; + + $expectedArray = [ + 'version' => '1.0', + 'charset' => 'UTF-8', + 'root' => [ + 'name' => 'Root', + 'children' => [ + [ + 'name' => 'FirstChildSecondElement', + 'children' => [ + [ + 'content' => 'Example Test', + 'matcher' => ['pact:matcher:type' => 'type'], + ], + ], + 'attributes' => [], + ], + [ + 'name' => 'SecondParent', + 'children' => [ + [ + 'name' => 'Secondchild1', + 'children' => [], + 'attributes' => ['myAttr' => 'Attr Value'], + ], + [ + 'name' => 'Secondchild2', + 'children' => [['content' => 'Test']], + 'attributes' => [], + ], + [ + 'name' => 'ThirdParent', + 'children' => [ + [ + 'value' => [ + 'name' => 'Child', + 'children' => [], + 'attributes' => [], + ], + 'pact:matcher:type' => 'type', + 'min' => 1, + 'examples' => 1, + ], + ], + 'attributes' => [], + ], + ], + 'attributes' => [], + ], + [ + 'name' => 'FirstChildThirdElement', + 'children' => [], + 'attributes' => [], + ], + ], + 'attributes' => [], + ], + ]; + + + $this->assertSame(json_encode($expectedArray), json_encode($builder->getArray())); + } +} diff --git a/tests/PhpPact/Xml/XmlElementTest.php b/tests/PhpPact/Xml/XmlElementTest.php new file mode 100644 index 00000000..66fa3127 --- /dev/null +++ b/tests/PhpPact/Xml/XmlElementTest.php @@ -0,0 +1,86 @@ +element = new XmlElement(); + $this->element->setName('Child'); + $this->element->addAttribute('myAttr', 'attr-value'); + } + + public function testGetMatcherArray(): void + { + $this->element->setMatcher(new Matcher( + fn (Matcher $matcher) => $matcher->setType('type'), + fn (Matcher $matcher) => $matcher->setOptions(['examples' => 7]), + )); + + $this->assertSame( + json_encode([ + 'value' => [ + 'name' => 'Child', + 'children' => [], + 'attributes' => [ + 'myAttr' => 'attr-value', + ], + ], + 'pact:matcher:type' => 'type', + 'examples' => 7, + ]), + json_encode($this->element->getArray()) + ); + } + + public function testGetGeneratorArray(): void + { + $this->element->setMatcher(new Matcher( + fn (Matcher $matcher) => $matcher->setType('type'), + fn (Matcher $matcher) => $matcher->setOptions(['examples' => 7]), + )); + $this->element->setGenerator(new Generator( + fn (Generator $generator) => $generator->setType('Uuid'), + fn (Generator $generator) => $generator->setOptions(['format' => 'simple']), + )); + + $this->assertSame( + json_encode([ + 'value' => [ + 'name' => 'Child', + 'children' => [], + 'attributes' => [ + 'myAttr' => 'attr-value', + ] + ], + 'pact:matcher:type' => 'type', + 'examples' => 7, + 'pact:generator:type' => 'Uuid', + 'format' => 'simple', + ]), + json_encode($this->element->getArray()) + ); + } + + public function testGetBaseArray(): void + { + $this->assertSame( + json_encode([ + 'name' => 'Child', + 'children' => [], + 'attributes' => [ + 'myAttr' => 'attr-value', + ] + ]), + json_encode($this->element->getArray()) + ); + } +} diff --git a/tests/PhpPact/Xml/XmlTextTest.php b/tests/PhpPact/Xml/XmlTextTest.php new file mode 100644 index 00000000..7371664e --- /dev/null +++ b/tests/PhpPact/Xml/XmlTextTest.php @@ -0,0 +1,73 @@ +text = new XmlText(); + $this->text->setContent('testing'); + } + + public function testGetMatcherArray(): void + { + $this->text->setMatcher(new Matcher( + fn (Matcher $matcher) => $matcher->setType('include'), + fn (Matcher $matcher) => $matcher->setOptions(['value' => "te"]), + )); + + $this->assertSame( + json_encode([ + 'content' => 'testing', + 'matcher' => [ + 'pact:matcher:type' => 'include', + 'value' => 'te', + ] + ]), + json_encode($this->text->getArray()) + ); + } + + public function testGetGeneratorArray(): void + { + $this->text->setContent(7); + $this->text->setMatcher(new Matcher( + fn (Matcher $matcher) => $matcher->setType('integer'), + )); + $this->text->setGenerator(new Generator( + fn (Generator $generator) => $generator->setType('RandomInt'), + fn (Generator $generator) => $generator->setOptions(['min' => 2, 'max' => 8]), + )); + + $this->assertSame( + json_encode([ + 'content' => 7, + 'matcher' => [ + 'pact:matcher:type' => 'integer', + 'min' => 2, + 'max' => 8, + ], + 'pact:generator:type' => 'RandomInt' + ]), + json_encode($this->text->getArray()) + ); + } + + public function testGetBaseArray(): void + { + $this->assertSame( + json_encode([ + 'content' => 'testing', + ]), + json_encode($this->text->getArray()) + ); + } +}