From 7468beb8752d9ee489d7e28ddc55606cfdc42216 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Wed, 27 Nov 2019 13:58:58 +0000 Subject: [PATCH] Simplify the mechanisms behind bind* functions. (#111) * Fix return type for getElementById, closes #65 * Update PHPDoc to include inherited changes * Rename function for removing template attributes * Set value for certain input fields differently * Bind list to document fragment for efficiency for #77 * Remove unbindable check * Allow returning any iterable, not just array - fixes #88 * Test that multiple kvps can be bound within the same parameter * Isolate bug for #105 - use README example * Rename BindDataGetter -> BindObject * Tidy up bindData function * Test incompatible bindData types * Remove bindNestedList function * Testing bindValue * Test bindObjectValue * Test bindValue within lists * Bindable type checking * Simplify bind functions, closes #110 * Skip empty lists --- README.md | 3 +- example/01-example-groceries.html | 6 + example/01-example-groceries.php | 20 + example/_component/shopping-list.html | 3 + src/BindDataGetter.php | 16 - src/BindDataMapper.php | 2 +- src/BindObject.php | 15 + src/Bindable.php | 307 +++++++++++---- src/HTMLDocument.php | 20 + src/IncompatibleBindDataException.php | 4 + src/TemplateElementNotFoundFoundException.php | 4 + test/unit/BindDataGetterTest.php | 2 +- test/unit/BindableTest.php | 371 ++++++++++++------ test/unit/Helper/BindDataGetter/TodoItem.php | 4 +- test/unit/Helper/Helper.php | 124 +++++- 15 files changed, 681 insertions(+), 220 deletions(-) create mode 100644 example/01-example-groceries.html create mode 100644 example/01-example-groceries.php create mode 100644 example/_component/shopping-list.html delete mode 100644 src/BindDataGetter.php create mode 100644 src/BindObject.php create mode 100644 src/IncompatibleBindDataException.php create mode 100644 src/TemplateElementNotFoundFoundException.php diff --git a/README.md b/README.md index 044a1fb..0fd29a1 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Consider a page with an unordered list (`