-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #228 from prooph/conveniencemethods
Add convenience methods to event store
- Loading branch information
Showing
8 changed files
with
212 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/** | ||
* This file is part of the prooph/event-store. | ||
* (c) 2014-2016 prooph software GmbH <[email protected]> | ||
* (c) 2015-2016 Sascha-Oliver Prolic <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Prooph\EventStore\Projection; | ||
|
||
use Prooph\EventStore\Exception\InvalidArgumentException; | ||
|
||
class ProjectionOptions | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
protected $cacheSize; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected $persistBlockSize; | ||
|
||
public function __construct(int $cacheSize = 1000, int $persistBlockSize = 1000) | ||
{ | ||
$this->cacheSize = $cacheSize; | ||
$this->persistBlockSize = $persistBlockSize; | ||
} | ||
|
||
public static function fromArray(array $data): ProjectionOptions | ||
{ | ||
self::validateData($data); | ||
|
||
return new self($data['cache_size'], $data['persist_block_size']); | ||
} | ||
|
||
public function cacheSize(): int | ||
{ | ||
return $this->cacheSize; | ||
} | ||
|
||
public function persistBlockSize(): int | ||
{ | ||
return $this->persistBlockSize; | ||
} | ||
|
||
/** | ||
* @throws InvalidArgumentException | ||
*/ | ||
protected static function validateData(array $data): void | ||
{ | ||
if (! isset($data['cache_size'])) { | ||
throw new InvalidArgumentException('cache_size option is missing'); | ||
} | ||
|
||
if (! isset($data['persist_block_size'])) { | ||
throw new InvalidArgumentException('persist_block_size option is missing'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,6 @@ public function reset(): void | |
|
||
public function delete(): void | ||
{ | ||
$this->storage = []; | ||
$this->storage = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.