forked from carferdas/curso-cf-php-poo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Request.php
executable file
·44 lines (36 loc) · 885 Bytes
/
Request.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php namespace Config;
class Request{
private $controlador;
private $metodo;
private $argumento;
public function __construct(){
if(isset($_GET['url'])){
$ruta = filter_input(INPUT_GET, 'url', FILTER_SANITIZE_URL);
$ruta = explode("/", $ruta);
$ruta = array_filter($ruta);
if($ruta[0] == "index.php"){
$this->controlador = "estudiantes";
}else{
$this->controlador = strtolower(array_shift($ruta));
}
$this->metodo = strtolower(array_shift($ruta));
if(!$this->metodo){
$this->metodo = "index";
}
$this->argumento = $ruta;
}else{
$this->controlador = "estudiantes";
$this->metodo = "index";
}
}
public function getControlador(){
return $this->controlador;
}
public function getMetodo(){
return $this->metodo;
}
public function getArgumento(){
return $this->argumento;
}
}
?>