| Total Complexity | 5 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class Url |
||
| 14 | { |
||
| 15 | private $controller; |
||
| 16 | private $action; |
||
| 17 | private $id; |
||
| 18 | private $add; |
||
| 19 | private $query; |
||
| 20 | private $encode = false; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Url constructor. Create instance before process params |
||
| 24 | * @param string $controllerAction |
||
| 25 | * @param null|string $id |
||
| 26 | * @param null|string $add |
||
| 27 | * @param array|null $query |
||
| 28 | * @param bool $encode |
||
| 29 | */ |
||
| 30 | public function __construct(string $controllerAction, ?string $id, ?string $add, ?array $query = null, bool $encode = false) |
||
| 31 | { |
||
| 32 | $controllerAction = Str::lowerCase(trim($controllerAction, '/')); |
||
| 33 | [$controller, $action] = explode('/', $controllerAction); |
||
| 34 | |||
| 35 | $this->controller = $controller; |
||
| 36 | $this->action = $action; |
||
| 37 | $this->id = $id; |
||
| 38 | $this->add = $add; |
||
| 39 | $this->query = $query; |
||
| 40 | $this->encode = $encode; |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Build link from passed params. Old method Url::to() -> Url::href |
||
| 45 | * @param array|null $to |
||
| 46 | * @param bool $encode |
||
| 47 | * @return null|string |
||
| 48 | */ |
||
| 49 | public static function href(?array $to = null, bool $encode = false): ?string |
||
| 57 | } |
||
| 58 | |||
| 59 | private function buildLinkString() |
||
| 62 | } |
||
| 63 | } |