From 058248271ec19eb0cb463272fe8308750d949540 Mon Sep 17 00:00:00 2001 From: codeliner Date: Sun, 15 Oct 2017 20:13:58 +0200 Subject: [PATCH 1/3] Restructure docs --- composer.json | 4 +++- docs/bookdown.json | 6 ++++-- docs/introduction.md | 13 +++++++++++++ src/MemcachedSnapshotStore.php | 4 ++-- .../Container/MemcachedSnapshotStoreFactoryTest.php | 4 +++- 5 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 docs/introduction.md diff --git a/composer.json b/composer.json index ccc8b7c..d905fb7 100644 --- a/composer.json +++ b/composer.json @@ -62,10 +62,12 @@ "scripts": { "check": [ "@cs", - "@test" + "@test", + "@docheader" ], "cs": "php-cs-fixer fix -v --diff --dry-run", "cs-fix": "php-cs-fixer fix -v --diff", + "docheader": "docheader check src/ tests/", "test": "phpunit" } } diff --git a/docs/bookdown.json b/docs/bookdown.json index baf3346..44931fc 100644 --- a/docs/bookdown.json +++ b/docs/bookdown.json @@ -1,9 +1,11 @@ { - "title": "Prooph Memcached SnapshotStore", + "title": "Memcached Snapshot Store", "content": [ - {"intro": "../README.md"}, + {"intro": "introduction.md"}, {"interop_factories": "interop_factories.md"} ], + "tocDepth": 1, + "numbering": false, "target": "./html", "template": "../vendor/prooph/bookdown-template/templates/main.php" } diff --git a/docs/introduction.md b/docs/introduction.md new file mode 100644 index 0000000..78779dd --- /dev/null +++ b/docs/introduction.md @@ -0,0 +1,13 @@ +# Overview + +Memcached implementation of snapshot store + +## Installation + +```bash +composer require prooph/memcached-snapshot-store +``` + +## Requirements + +- ext-memcached ^3.0 \ No newline at end of file diff --git a/src/MemcachedSnapshotStore.php b/src/MemcachedSnapshotStore.php index 2bb1e24..9ed33f1 100644 --- a/src/MemcachedSnapshotStore.php +++ b/src/MemcachedSnapshotStore.php @@ -71,7 +71,7 @@ public function save(Snapshot ...$snapshots): void $snapshot->aggregateType(), $snapshot->lastVersion(), $snapshot->createdAt()->format('Y-m-d\TH:i:s.u'), - $this->serializer->serialize($snapshot->aggregateRoot()) + $this->serializer->serialize($snapshot->aggregateRoot()), ]; } @@ -82,7 +82,7 @@ public function removeAll(string $aggregateType): void { $keys = $this->connection->getAllKeys(); - foreach($keys as $item) { + foreach ($keys as $item) { if (substr($item, 0, strlen($aggregateType)) === $aggregateType) { $this->connection->delete($item); } diff --git a/tests/Container/MemcachedSnapshotStoreFactoryTest.php b/tests/Container/MemcachedSnapshotStoreFactoryTest.php index 6c6a262..0a903c3 100644 --- a/tests/Container/MemcachedSnapshotStoreFactoryTest.php +++ b/tests/Container/MemcachedSnapshotStoreFactoryTest.php @@ -71,7 +71,9 @@ public function it_gets_serializer_from_container_when_not_instanceof_serializer $container->get('my_connection')->willReturn($connection)->shouldBeCalled(); $container->get('config')->willReturn($config)->shouldBeCalled(); - $container->get('serializer_servicename')->willReturn(new CallbackSerializer(function() {}, function() {}))->shouldBeCalled(); + $container->get('serializer_servicename')->willReturn(new CallbackSerializer(function () { + }, function () { + }))->shouldBeCalled(); $factory = new MemcachedSnapshotStoreFactory(); $snapshotStore = $factory($container->reveal()); From df0f44c80dd7900252a456658e2a9624e0171b3f Mon Sep 17 00:00:00 2001 From: codeliner Date: Sun, 15 Oct 2017 20:38:05 +0200 Subject: [PATCH 2/3] Add missing phpunit config --- phpunit.xml.dist | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 phpunit.xml.dist diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..479e6f0 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,22 @@ + + + + ./tests/ + + + + + ./src/ + + + From 1821cdddbb46a1e874239b1bf443696a59d61e3e Mon Sep 17 00:00:00 2001 From: codeliner Date: Sun, 15 Oct 2017 20:46:22 +0200 Subject: [PATCH 3/3] Add memcached connection --- phpunit.xml.dist | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 479e6f0..98ea55f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -19,4 +19,9 @@ ./src/ + + + + +