for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Webino (http://webino.sk)
*
* @link https://github.com/webino for the canonical source repository
* @copyright Copyright (c) 2015-2017 Webino, s.r.o. (http://webino.sk)
* @author Peter Bačinský <[email protected]>
* @license BSD-3-Clause
*/
namespace WebinoConfigLib\Router\Route\Regex;
use WebinoConfigLib\Router\RouteInterface;
* Trait RouteConstructorTrait
trait RouteConstructorTrait
{
* @var string
private $path;
private $spec;
* {@inheritdoc}
* @see \WebinoConfigLib\Router\Route\Regex\RouteConstructorInterface
public function __construct($path, $spec = null)
$this
->setPath($path)
->setSpec($spec)
->setType(RouteInterface::REGEX)
->init();
}
* @param string $type Route type.
* @return $this
abstract public function setType($type = RouteInterface::LITERAL);
* Initialize route
* @return void
abstract protected function init();
* @return bool
protected function hasRoute()
return !empty($this->route);
route
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 string
protected function getPath()
return $this->path;
* @param string|null $path
public function setPath($path = null)
$this->path = (string) $path;
return $this;
protected function hasSpec()
return !empty($this->spec);
protected function getSpec()
return $this->spec;
* @param string|null $spec
protected function setSpec($spec = null)
$this->spec = (string) $spec;
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: