1234567891011121314151617181920212223242526272829303132 |
- <?php
- class Url {
- private $path;
- private $arguments;
- public function __construct($path, $arguments) {
- $this->path = $path;
- $this->arguments = $arguments;
- }
- public function getPath() {
- return $this->path;
- }
- public function getPathElement($index) {
- return $this->path[$index];
- }
- public function getArgs() {
- return $this->arguments;
- }
- public function getArgumentElement($index) {
- return $this->arguments[$index];
- }
- public function toString() {
- $urlString = "/" . implode("/", $this->path);
- if(count($this->arguments) > 0) {
- $parts = array();
- foreach($this->arguments as $variable => $value) {
- $parts[] = $variable . "=" . $value;
- }
- $urlString .= "?" . implode("&", $parts);
- }
- return $urlString;
- }
- }
|