mirror of
https://github.com/kevinveenbirkenbach/coding-challenge-online-shop.git
synced 2025-09-10 03:47:13 +02:00
Listed all options
This commit is contained in:
@@ -6,7 +6,7 @@ namespace router;
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
class Url
|
||||
class Link
|
||||
{
|
||||
/**
|
||||
* ArrayCollection would be nicer but I have to save time ;)
|
||||
@@ -14,19 +14,39 @@ class Url
|
||||
*/
|
||||
private $parameters;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
public function __construct(array $parameters=[],string $name = ''){
|
||||
$this->setParameters($parameters);
|
||||
$this->setName($name);
|
||||
}
|
||||
|
||||
public function setParameters(array $parameters):void{
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
public function setName(string $name):void{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getName():string{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getUrl():string{
|
||||
return "index.php".$this->getParameters();
|
||||
}
|
||||
|
||||
private function getParameters():string{
|
||||
$parameters = '?';
|
||||
foreach ($parameters as $key=>$value){
|
||||
foreach ($this->parameters as $key=>$value){
|
||||
$parameters .= $key.'='.$value.'&';
|
||||
}
|
||||
return $parameters;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user