for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace nebula\route;
use Iterator;
use ArrayIterator;
use nebula\route\collection\CollectionFile;
/**
* 路由集合
*
*/
class RouteCollection extends CollectionFile
{
* 属性
* @var RouteMatcher[]
protected $collection = [];
* 创建集合
* @param RouteMatcher[] $collection
public function __construct(array $collection=[])
$this->merge($collection);
}
* 合并集合
* @param array $collection
* @return void
public function merge(array $collection=[])
$this->collection = array_merge($this->collection, $collection);
* 添加集合
* @param string $name
* @param RouteMatcher $collection
public function add(string $name, RouteMatcher $collection)
$this->collection[$name] = $collection;
* 获取集合
* @return RouteMatcher|null
public function get(string $name):?RouteMatcher
return $this->collection[$name] ?? null;
* 获取迭代器
* @return RouteMatcher[]
public function getCollection():array
return $this->collection;