Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/tests/Url/QAToolsUrlBuilder.php
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | LF |
svn:keywords | null | Id |
<?php | |||||
/** | |||||
* @version $Id$ | |||||
* @package In-Portal | |||||
* @copyright Copyright (C) 1997 - 2023 Intechnic. All rights reserved. | |||||
* @license GNU/GPL | |||||
* In-Portal is Open Source software. | |||||
* This means that this software may have been modified pursuant | |||||
* the GNU General Public License, and as distributed it includes | |||||
* or is derivative of works licensed under the GNU General Public License | |||||
* or other free or open source software licenses. | |||||
* See http://www.in-portal.org/license for copyright notices and details. | |||||
*/ | |||||
use QATools\QATools\PageObject\Exception\UrlException; | |||||
use QATools\QATools\PageObject\Url\IBuilder; | |||||
final class QAToolsUrlBuilder extends kBase implements IBuilder | |||||
{ | |||||
/** | |||||
* Template. | |||||
* | |||||
* @var string | |||||
*/ | |||||
protected $template = ''; | |||||
/** | |||||
* Params. | |||||
* | |||||
* @var array | |||||
*/ | |||||
protected $params = array(); | |||||
/** | |||||
* Constructor for the url builder. | |||||
* | |||||
* @param array $components The url components. | |||||
* | |||||
* @throws UrlException When the path is missing. | |||||
*/ | |||||
public function __construct(array $components) | |||||
{ | |||||
parent::__construct(); | |||||
if ( empty($components['path']) ) { | |||||
throw new UrlException('No base url specified', UrlException::TYPE_INVALID_URL); | |||||
} | |||||
$this->template = $components['path']; | |||||
if ( !empty($components['query']) ) { | |||||
parse_str($components['query'], $this->params); | |||||
} | |||||
} | |||||
/** | |||||
* @inheritDoc | |||||
*/ | |||||
public function build(array $params = array()) | |||||
{ | |||||
return $this->Application->HREF($this->template, '', array_merge($this->params, $params)); | |||||
} | |||||
} |