Source of file Director.php

Size: 1,498 Bytes - Last Modified: 2016-08-17T22:25:24+00:00

../src/Aviat/Director/Director.php

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
<?php
/**
 * Director
 *
 * A general purpose url router and generator
 *
 * @package     Director
 * @author      Timothy J. Warren
 * @copyright   Copyright (c) 2016
 * @link        https://git.timshomepage.net/timw4mail/director
 * @license     MIT
 */

namespace Aviat\Director;

use Psr\Log\LoggerInterface;

/**
 * Library entry point
 */
class Director {

	/**
	 * Route configuration
	 *
	 * @var RouteConfig
	 */
	protected $config;
	
	/**
	 * Url Generator 
	 *
	 * @var UrlGenerator
	 */
	protected $urlGenerator;
	
	/**
	 * Route matcher
	 *
	 * @var Matcher
	 */
	protected $matcher;
	
	/**
	 * Logger
	 *
	 * @var LoggerInterface
	 */
	protected $logger;
	
	/**
	 * Constructor
	 *
	 * @param [array] $config - The full route configuration
	 */
	public function __construct(array $config = [])
	{
		$this->config = $this->getNewConfig();
		$this->matcher = $this->getMatcher();
		$this->urlGenerator = $this->getUrlGenerator();
	}
	
	/**
	 * Return the config option
	 *
	 * @return RouteConfig
	 */
	public function getConfig()
	{
		return $this->config;
	}
	
	/**
	 * Create config object
	 *
	 * @return RouteConfig
	 */
	protected function getNewConfig()
	{
		return new RouteConfig();
	}
	
	/**
	 * Create matcher object
	 *
	 * @return Matcher
	 */
	protected function getMatcher()
	{
		return new Matcher($this->config);
	}
	
	/**
	 * Create url generator
	 *
	 * @return UrlGenerator
	 */
	protected function getUrlGenerator()
	{
		return new UrlGenerator($this->config);
	}
}