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:
52
src/router/Link.php
Normal file
52
src/router/Link.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace router;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
class Link
|
||||
{
|
||||
/**
|
||||
* ArrayCollection would be nicer but I have to save time ;)
|
||||
* @var array
|
||||
*/
|
||||
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 ($this->parameters as $key=>$value){
|
||||
$parameters .= $key.'='.$value.'&';
|
||||
}
|
||||
return $parameters;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user