for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Pagerfanta package.
*
* (c) Pablo Díez <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Pagerfanta\View;
use Pagerfanta\Exception\InvalidArgumentException;
/**
* ViewFactory.
* @author Pablo Díez <[email protected]>
class ViewFactory implements ViewFactoryInterface
{
private $views;
* Constructor.
public function __construct()
$this->views = array();
}
* {@inheritdoc}
public function set($name, ViewInterface $view)
$this->views[$name] = $view;
public function has($name)
return isset($this->views[$name]);
public function add(array $views)
foreach ($views as $name => $view) {
$this->set($name, $view);
public function get($name)
if (!$this->has($name)) {
throw new InvalidArgumentException(sprintf('The view "%s" does not exist.', $name));
return $this->views[$name];
public function remove($name)
unset($this->views[$name]);
public function all()
return $this->views;
public function clear()