for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Nip\Router\Router\Traits;
use Nip\Router\Route\Route;
use Nip\Router\RouteCollection;
/**
* Class HasRouteCollectionTrait
* @package Nip\Router\Router\Traits
*/
trait HasRouteCollectionTrait
{
* @inheritdoc
* @return RouteCollection
public function getRouteCollection()
if (null === $this->collection) {
$this->collection = $this->newRoutesCollection();
collection
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
return parent::getRouteCollection();
* @param $name
* @return null|Route\Route
public function getRoute($name)
return $this->getRouteCollection()->get($name);
* @return RouteCollection|Route[]
public function getRoutes()
return $this->getRouteCollection();
* @return bool
public function connected($name)
return ($this->getRoute($name) instanceof Route);
* @param Route $route
public function addRoute($route)
$this->getRouteCollection()->addRoute($route);
* @param string $name
public function hasRoute($name)
return $this->getRoutes()->has($name);
protected function newRoutesCollection()
return new RouteCollection();
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: