Skip to content

Commit f198ba7

Browse files
committed
Initial commit
1 parent 42f65ea commit f198ba7

10 files changed

+217
-0
lines changed

Diff for: .docheader

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* This file is part of event-engine/php-event-store.
3+
* (c) 2018-%year% prooph software GmbH <[email protected]>
4+
*
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*/

Diff for: .gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/ export-ignore

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
composer.lock
3+
vendor

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018-2019 prooph software GmbH
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# php-event-store
2+
23
Event Engine PHP Event Store Contract

Diff for: composer.json

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "event-engine/php-event-store",
3+
"description": "Event Engine PHP Event Store Contract",
4+
"homepage": "https://event-engine.io/",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Alexander Miertsch",
9+
"email": "[email protected]",
10+
"homepage": "http://www.prooph.de"
11+
},
12+
{
13+
"name": "Sandro Keil",
14+
"email": "[email protected]",
15+
"homepage": "http://prooph-software.com/"
16+
}
17+
],
18+
"require": {
19+
"php": "^7.2",
20+
"roave/security-advisories": "dev-master"
21+
},
22+
"require-dev": {
23+
"phpunit/phpunit": "^7.0",
24+
"prooph/php-cs-fixer-config": "^0.3",
25+
"satooshi/php-coveralls": "^1.0",
26+
"malukenho/docheader": "^0.1.4"
27+
},
28+
"autoload": {
29+
"psr-4": {
30+
"EventEngine\\EventStore\\": "src/"
31+
}
32+
},
33+
"autoload-dev": {
34+
"psr-4": {
35+
"EventEngineTest\\EventStore\\": "tests/"
36+
}
37+
},
38+
"prefer-stable": true,
39+
"scripts": {
40+
"check": [
41+
"@cs",
42+
"@docheader",
43+
"@test"
44+
],
45+
"docheader": "vendor/bin/docheader check examples/ src/ tests/",
46+
"cs": "php-cs-fixer fix -v --diff --dry-run",
47+
"cs-fix": "php-cs-fixer fix -v --diff",
48+
"test": "vendor/bin/phpunit"
49+
}
50+
}

Diff for: phpunit.xml.dist

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
colors="true"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
processIsolation="false"
9+
stopOnFailure="false"
10+
bootstrap="vendor/autoload.php"
11+
>
12+
<testsuite name="prooph software Event Engine Test Suite">
13+
<directory>./tests/</directory>
14+
</testsuite>
15+
16+
<filter>
17+
<whitelist>
18+
<directory>./src/</directory>
19+
</whitelist>
20+
</filter>
21+
</phpunit>

Diff for: src/EventStore.php

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* This file is part of event-engine/php-event-store.
4+
* (c) 2018-2019 prooph software GmbH <[email protected]>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
declare(strict_types=1);
11+
12+
namespace EventEngine\EventStore;
13+
14+
use EventEngine\Messaging\GenericEvent;
15+
16+
interface EventStore
17+
{
18+
public function createStream(string $streamName): void;
19+
20+
public function deleteStream(string $streamName): void;
21+
22+
public function appendTo(string $streamName, GenericEvent ...$events): void;
23+
24+
/**
25+
* @param string $streamName
26+
* @param string $aggregateType
27+
* @param string $aggregateId
28+
* @param int $minVersion
29+
* @return \Iterator GenericEvent[]
30+
*/
31+
public function loadAggregateEvents(string $streamName, string $aggregateType, string $aggregateId, int $minVersion = 1): \Iterator;
32+
33+
/**
34+
* @param string $streamName
35+
* @param string $correlationId
36+
* @return \Iterator GenericEvent[]
37+
*/
38+
public function loadEventsByCorrelationId(string $streamName, string $correlationId): \Iterator;
39+
40+
/**
41+
* @param string $streamName
42+
* @param string $causationId
43+
* @return \Iterator GenericEvent[]
44+
*/
45+
public function loadEventsByCausationId(string $streamName, string $causationId): \Iterator;
46+
}

Diff for: src/EventStream.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* This file is part of event-engine/php-event-store.
4+
* (c) 2018-2019 prooph software GmbH <[email protected]>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
declare(strict_types=1);
11+
12+
namespace EventEngine\EventStore;
13+
14+
use EventEngine\EventStore\Stream\WatcherId;
15+
16+
interface EventStream
17+
{
18+
public function watch(string $streamName, callable $onEvent, string $lastEventId = null): WatcherId;
19+
20+
public function stopWatcher(WatcherId $watcherId): void;
21+
}

Diff for: src/Stream/WatcherId.php

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* This file is part of event-engine/php-event-store.
4+
* (c) 2018-2019 prooph software GmbH <[email protected]>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
declare(strict_types=1);
11+
12+
namespace EventEngine\EventStore\Stream;
13+
14+
final class WatcherId
15+
{
16+
private $watchrId;
17+
18+
public static function fromString(string $watchrId): self
19+
{
20+
return new self($watchrId);
21+
}
22+
23+
private function __construct(string $watchrId)
24+
{
25+
$this->watchrId = $watchrId;
26+
}
27+
28+
public function toString(): string
29+
{
30+
return $this->watchrId;
31+
}
32+
33+
public function equals($other): bool
34+
{
35+
if(!$other instanceof self) {
36+
return false;
37+
}
38+
39+
return $this->watchrId === $other->watchrId;
40+
}
41+
42+
public function __toString(): string
43+
{
44+
return $this->watchrId;
45+
}
46+
}

0 commit comments

Comments
 (0)