for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the puli/repository package.
*
* (c) Bernhard Schussek <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Puli\Repository\ChangeStream;
use Puli\Repository\Api\ChangeStream\ChangeStream;
use Puli\Repository\Api\Resource\PuliResource;
use Puli\Repository\Api\ResourceRepository;
/**
* ChangeStream stored in memory (as an array).
* @since 1.0
* @author Titouan Galopin <[email protected]>
class InMemoryChangeStream implements ChangeStream
{
* @var array
private $stack = array();
* @inheritdoc
public function log($path, PuliResource $resource)
if (!array_key_exists($path, $this->stack)) {
$this->stack[$path] = array();
}
$this->stack[$path][] = serialize($resource);
public function buildResourceStack(ResourceRepository $repository, $path)
$stack = array();
if (isset($this->stack[$path]) && is_array($this->stack[$path])) {
foreach ($this->stack[$path] as $data) {
$resource = unserialize($data);
$resource->attachTo($repository, $path);
$stack[] = $resource;
return new ArrayResourceStack($stack);