for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Borobudur-Cqrs package.
*
* (c) Hexacodelabs <http://hexacodelabs.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Borobudur\Cqrs\ViewModel;
use ArrayIterator;
use Borobudur\Cqrs\Exception\BadMethodCallException;
/**
* @author Iqbal Maulana <[email protected]>
* @created 8/20/15
abstract class AbstractViewModel implements ViewModelInterface
{
* {@inheritdoc}
public function getIterator()
return new ArrayIterator($this->build());
}
public function offsetExists($offset)
$builds = $this->build();
return isset($builds[$offset]);
public function offsetGet($offset)
if (isset($builds[$offset])) {
return $builds[$offset];
return null;
public function offsetSet($offset, $value)
throw BadMethodCallException::immutableViewModel();
public function offsetUnset($offset)
* Register fields that should be viewed.
* @return array|null
abstract protected function fields();
* Append custom fields.
abstract protected function append();
* Register hidden fields.
abstract protected function hidden();