Add Text and Data to PreCalc

This commit is contained in:
Thomas Peterson 2025-04-28 09:24:05 +02:00
parent 97e5cd6639
commit 22fc619cf5
5 changed files with 189 additions and 75 deletions

223
composer.lock generated
View File

@ -159,25 +159,25 @@
},
{
"name": "bitandblack/sentence-construction",
"version": "2.1.0",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://bitbucket.org/wirbelwild/sentence-construction.git",
"reference": "a676cf6a7f6e3673b987f16995f82bbbba1e4600"
"reference": "1c1ca8fa2bef4597c5f486bf3d736f3ebd229f17"
},
"dist": {
"type": "zip",
"url": "https://bitbucket.org/wirbelwild/sentence-construction/get/a676cf6a7f6e3673b987f16995f82bbbba1e4600.zip",
"reference": "a676cf6a7f6e3673b987f16995f82bbbba1e4600",
"url": "https://bitbucket.org/wirbelwild/sentence-construction/get/1c1ca8fa2bef4597c5f486bf3d736f3ebd229f17.zip",
"reference": "1c1ca8fa2bef4597c5f486bf3d736f3ebd229f17",
"shasum": ""
},
"require": {
"php": ">=8.0"
},
"require-dev": {
"phpstan/phpstan": "^1.0",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^10.0",
"rector/rector": "^1.0",
"rector/rector": "^2.0",
"symplify/easy-coding-standard": "^12.0"
},
"suggest": {
@ -200,7 +200,7 @@
"homepage": "https://www.bitandblack.com"
}
],
"description": "Creates nice sentences",
"description": "Creates nice sentences out of arrays",
"homepage": "https://www.bitandblack.com",
"keywords": [
"grammar",
@ -209,7 +209,7 @@
"words"
],
"support": {
"source": "https://bitbucket.org/wirbelwild/sentence-construction/src/a676cf6a7f6e3673b987f16995f82bbbba1e4600/?at=2.1.0"
"source": "https://bitbucket.org/wirbelwild/sentence-construction/src/1c1ca8fa2bef4597c5f486bf3d736f3ebd229f17/?at=2.2.0"
},
"funding": [
{
@ -217,7 +217,7 @@
"type": "buymeacoffee"
}
],
"time": "2024-12-09T08:20:53+00:00"
"time": "2025-04-14T06:21:22+00:00"
},
{
"name": "doctrine/cache",
@ -314,29 +314,29 @@
},
{
"name": "doctrine/collections",
"version": "2.2.2",
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/collections.git",
"reference": "d8af7f248c74f195f7347424600fd9e17b57af59"
"reference": "2eb07e5953eed811ce1b309a7478a3b236f2273d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/collections/zipball/d8af7f248c74f195f7347424600fd9e17b57af59",
"reference": "d8af7f248c74f195f7347424600fd9e17b57af59",
"url": "https://api.github.com/repos/doctrine/collections/zipball/2eb07e5953eed811ce1b309a7478a3b236f2273d",
"reference": "2eb07e5953eed811ce1b309a7478a3b236f2273d",
"shasum": ""
},
"require": {
"doctrine/deprecations": "^1",
"php": "^8.1"
"php": "^8.1",
"symfony/polyfill-php84": "^1.30"
},
"require-dev": {
"doctrine/coding-standard": "^12",
"ext-json": "*",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^10.5",
"vimeo/psalm": "^5.11"
"phpunit/phpunit": "^10.5"
},
"type": "library",
"autoload": {
@ -380,7 +380,7 @@
],
"support": {
"issues": "https://github.com/doctrine/collections/issues",
"source": "https://github.com/doctrine/collections/tree/2.2.2"
"source": "https://github.com/doctrine/collections/tree/2.3.0"
},
"funding": [
{
@ -396,7 +396,7 @@
"type": "tidelift"
}
],
"time": "2024-04-18T06:56:21+00:00"
"time": "2025-03-22T10:17:19+00:00"
},
{
"name": "doctrine/common",
@ -602,26 +602,29 @@
},
{
"name": "doctrine/deprecations",
"version": "1.1.4",
"version": "1.1.5",
"source": {
"type": "git",
"url": "https://github.com/doctrine/deprecations.git",
"reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9"
"reference": "459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/31610dbb31faa98e6b5447b62340826f54fbc4e9",
"reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38",
"reference": "459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"conflict": {
"phpunit/phpunit": "<=7.5 || >=13"
},
"require-dev": {
"doctrine/coding-standard": "^9 || ^12",
"phpstan/phpstan": "1.4.10 || 2.0.3",
"doctrine/coding-standard": "^9 || ^12 || ^13",
"phpstan/phpstan": "1.4.10 || 2.1.11",
"phpstan/phpstan-phpunit": "^1.0 || ^2",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.5 || ^11.5 || ^12",
"psr/log": "^1 || ^2 || ^3"
},
"suggest": {
@ -641,9 +644,9 @@
"homepage": "https://www.doctrine-project.org/",
"support": {
"issues": "https://github.com/doctrine/deprecations/issues",
"source": "https://github.com/doctrine/deprecations/tree/1.1.4"
"source": "https://github.com/doctrine/deprecations/tree/1.1.5"
},
"time": "2024-12-07T21:18:45+00:00"
"time": "2025-04-07T20:06:18+00:00"
},
{
"name": "doctrine/event-manager",
@ -976,16 +979,16 @@
},
{
"name": "doctrine/orm",
"version": "2.20.1",
"version": "2.20.2",
"source": {
"type": "git",
"url": "https://github.com/doctrine/orm.git",
"reference": "e3cabade99ebccc6ba078884c1c5f250866a494e"
"reference": "19912de9270fa6abb3d25a1a37784af6b818d534"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/orm/zipball/e3cabade99ebccc6ba078884c1c5f250866a494e",
"reference": "e3cabade99ebccc6ba078884c1c5f250866a494e",
"url": "https://api.github.com/repos/doctrine/orm/zipball/19912de9270fa6abb3d25a1a37784af6b818d534",
"reference": "19912de9270fa6abb3d25a1a37784af6b818d534",
"shasum": ""
},
"require": {
@ -1072,9 +1075,9 @@
],
"support": {
"issues": "https://github.com/doctrine/orm/issues",
"source": "https://github.com/doctrine/orm/tree/2.20.1"
"source": "https://github.com/doctrine/orm/tree/2.20.2"
},
"time": "2024-12-19T06:48:36+00:00"
"time": "2025-02-04T19:17:01+00:00"
},
{
"name": "doctrine/persistence",
@ -1389,46 +1392,47 @@
},
{
"name": "symfony/console",
"version": "v7.2.1",
"version": "v6.4.20",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "fefcc18c0f5d0efe3ab3152f15857298868dc2c3"
"reference": "2e4af9c952617cc3f9559ff706aee420a8464c36"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/fefcc18c0f5d0efe3ab3152f15857298868dc2c3",
"reference": "fefcc18c0f5d0efe3ab3152f15857298868dc2c3",
"url": "https://api.github.com/repos/symfony/console/zipball/2e4af9c952617cc3f9559ff706aee420a8464c36",
"reference": "2e4af9c952617cc3f9559ff706aee420a8464c36",
"shasum": ""
},
"require": {
"php": ">=8.2",
"php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-mbstring": "~1.0",
"symfony/service-contracts": "^2.5|^3",
"symfony/string": "^6.4|^7.0"
"symfony/string": "^5.4|^6.0|^7.0"
},
"conflict": {
"symfony/dependency-injection": "<6.4",
"symfony/dotenv": "<6.4",
"symfony/event-dispatcher": "<6.4",
"symfony/lock": "<6.4",
"symfony/process": "<6.4"
"symfony/dependency-injection": "<5.4",
"symfony/dotenv": "<5.4",
"symfony/event-dispatcher": "<5.4",
"symfony/lock": "<5.4",
"symfony/process": "<5.4"
},
"provide": {
"psr/log-implementation": "1.0|2.0|3.0"
},
"require-dev": {
"psr/log": "^1|^2|^3",
"symfony/config": "^6.4|^7.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/event-dispatcher": "^6.4|^7.0",
"symfony/config": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
"symfony/event-dispatcher": "^5.4|^6.0|^7.0",
"symfony/http-foundation": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/lock": "^6.4|^7.0",
"symfony/messenger": "^6.4|^7.0",
"symfony/process": "^6.4|^7.0",
"symfony/stopwatch": "^6.4|^7.0",
"symfony/var-dumper": "^6.4|^7.0"
"symfony/lock": "^5.4|^6.0|^7.0",
"symfony/messenger": "^5.4|^6.0|^7.0",
"symfony/process": "^5.4|^6.0|^7.0",
"symfony/stopwatch": "^5.4|^6.0|^7.0",
"symfony/var-dumper": "^5.4|^6.0|^7.0"
},
"type": "library",
"autoload": {
@ -1462,7 +1466,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v7.2.1"
"source": "https://github.com/symfony/console/tree/v6.4.20"
},
"funding": [
{
@ -1478,7 +1482,7 @@
"type": "tidelift"
}
],
"time": "2024-12-11T03:49:26+00:00"
"time": "2025-03-03T17:16:38+00:00"
},
{
"name": "symfony/deprecation-contracts",
@ -2010,6 +2014,82 @@
],
"time": "2024-09-09T11:45:10+00:00"
},
{
"name": "symfony/polyfill-php84",
"version": "v1.31.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php84.git",
"reference": "e5493eb51311ab0b1cc2243416613f06ed8f18bd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php84/zipball/e5493eb51311ab0b1cc2243416613f06ed8f18bd",
"reference": "e5493eb51311ab0b1cc2243416613f06ed8f18bd",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php84\\": ""
},
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 8.4+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php84/tree/v1.31.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-09T12:04:04+00:00"
},
{
"name": "symfony/service-contracts",
"version": "v3.5.1",
@ -2095,20 +2175,20 @@
},
{
"name": "symfony/string",
"version": "v7.2.0",
"version": "v6.4.15",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "446e0d146f991dde3e73f45f2c97a9faad773c82"
"reference": "73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/446e0d146f991dde3e73f45f2c97a9faad773c82",
"reference": "446e0d146f991dde3e73f45f2c97a9faad773c82",
"url": "https://api.github.com/repos/symfony/string/zipball/73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f",
"reference": "73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f",
"shasum": ""
},
"require": {
"php": ">=8.2",
"php": ">=8.1",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-intl-grapheme": "~1.0",
"symfony/polyfill-intl-normalizer": "~1.0",
@ -2118,12 +2198,11 @@
"symfony/translation-contracts": "<2.5"
},
"require-dev": {
"symfony/emoji": "^7.1",
"symfony/error-handler": "^6.4|^7.0",
"symfony/http-client": "^6.4|^7.0",
"symfony/intl": "^6.4|^7.0",
"symfony/error-handler": "^5.4|^6.0|^7.0",
"symfony/http-client": "^5.4|^6.0|^7.0",
"symfony/intl": "^6.2|^7.0",
"symfony/translation-contracts": "^2.5|^3.0",
"symfony/var-exporter": "^6.4|^7.0"
"symfony/var-exporter": "^5.4|^6.0|^7.0"
},
"type": "library",
"autoload": {
@ -2162,7 +2241,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v7.2.0"
"source": "https://github.com/symfony/string/tree/v6.4.15"
},
"funding": [
{
@ -2178,22 +2257,22 @@
"type": "tidelift"
}
],
"time": "2024-11-13T13:31:26+00:00"
"time": "2024-11-13T13:31:12+00:00"
}
],
"packages-dev": [
{
"name": "myclabs/deep-copy",
"version": "1.12.1",
"version": "1.13.0",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "123267b2c49fbf30d78a7b2d333f6be754b94845"
"reference": "024473a478be9df5fdaca2c793f2232fe788e414"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845",
"reference": "123267b2c49fbf30d78a7b2d333f6be754b94845",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/024473a478be9df5fdaca2c793f2232fe788e414",
"reference": "024473a478be9df5fdaca2c793f2232fe788e414",
"shasum": ""
},
"require": {
@ -2232,7 +2311,7 @@
],
"support": {
"issues": "https://github.com/myclabs/DeepCopy/issues",
"source": "https://github.com/myclabs/DeepCopy/tree/1.12.1"
"source": "https://github.com/myclabs/DeepCopy/tree/1.13.0"
},
"funding": [
{
@ -2240,7 +2319,7 @@
"type": "tidelift"
}
],
"time": "2024-11-08T17:47:46+00:00"
"time": "2025-02-12T12:17:51+00:00"
},
{
"name": "nikic/php-parser",

View File

@ -21,6 +21,15 @@ class Variant {
$obj->setName((string)$this->node['name']);
}
if(isset($this->node['text'])) {
$obj->setText((string)$this->node['text']);
}
if(isset($this->node['data'])) {
$obj->setData((string)$this->node['data']);
}
foreach($this->node->children() as $child) {
$valueParser = new Value($child);
$obj->addValue($valueParser->parse());

View File

@ -7,6 +7,8 @@ use ArrayIterator;
class Variant {
protected string $name = "";
protected string $text = "";
protected string $data = "";
protected float $price = 0;
@ -46,4 +48,20 @@ class Variant {
{
return $this->values;
}
public function getData():string {
return $this->data;
}
public function setData(string $data):void {
$this->data = $data;
}
public function getText():string {
return $this->text;
}
public function setText(string $text):void {
$this->text = $text;
}
}

View File

@ -26,4 +26,14 @@ class ParseTest extends TestCase
$this->assertSame(4, count($element->getGroups()[0]->getVariants()));
}
public function testText()
{
$parser = new PreCalc(simplexml_load_string(file_get_contents(__DIR__ . '/../TestFiles/PreCalc/precalc.xml')));
$element = $parser->parse();
$this->assertSame("auf anfrage", $element->getGroups()[0]->getVariants()[3]->getText());
}
}

View File

@ -12,9 +12,7 @@
<auflage>300</auflage>
<lochbohrung>2</lochbohrung>
</calc>
<calc name="400 stk">
<auflage>400</auflage>
<lochbohrung>2</lochbohrung>
<calc name="400 stk" text="auf anfrage" link="https://google.de">
</calc>
</group>
<group name="mit Lochbohrung">