thallesdella /
factory-router
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Controllers; |
||
| 4 | |||
| 5 | use CoffeeCode\Router\Router; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Factory Router | Class Website [ EXAMPLE ] |
||
| 9 | * |
||
| 10 | * @category Examples\Controllers |
||
| 11 | * @package FactoryRouter\Examples\Controllers |
||
| 12 | * @author Thalles D. koester <[email protected]> |
||
| 13 | * @license https://choosealicense.com/licenses/mit/ MIT |
||
| 14 | * @link https://github.com/thallesdella/factory-router |
||
| 15 | */ |
||
| 16 | class Website extends Controller |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * main constructor. |
||
| 20 | * |
||
| 21 | * @param Router $router |
||
| 22 | */ |
||
| 23 | public function __construct(Router $router) |
||
| 24 | { |
||
| 25 | parent::__construct($router); |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @return void |
||
| 30 | */ |
||
| 31 | public function home(?array $data): void |
||
|
0 ignored issues
–
show
|
|||
| 32 | { |
||
| 33 | $action = $this->router->route('website.login'); |
||
| 34 | $html = "<a title='Fazer Login' href='{$action}'>Fazer Login</a>"; |
||
| 35 | echo $html; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param array|null $data |
||
| 40 | * |
||
| 41 | * @return void |
||
| 42 | */ |
||
| 43 | public function login(?array $data): void |
||
| 44 | { |
||
| 45 | if (isset($_SESSION['login']) && $_SESSION['login'] == true) { |
||
| 46 | $this->router->redirect('app.home'); |
||
| 47 | } |
||
| 48 | |||
| 49 | $html = ''; |
||
| 50 | if (!empty($data['msg'])) { |
||
| 51 | $cleanMsg = filter_var( |
||
| 52 | base64_decode($data['msg']), |
||
| 53 | FILTER_SANITIZE_STRIPPED |
||
| 54 | ); |
||
| 55 | $html .= "{$cleanMsg}<br><br>"; |
||
| 56 | } |
||
| 57 | |||
| 58 | $action = $this->router->route('auth.login'); |
||
| 59 | $html .= "<form action='{$action}' method='post'> |
||
| 60 | <label> |
||
| 61 | <span>User:</span><input type='text' name='user' required> |
||
| 62 | </label><br> |
||
| 63 | <label> |
||
| 64 | <span>Pass:</span><input type='password' name='pass' required> |
||
| 65 | </label><br> |
||
| 66 | <button>Submit</button></form>"; |
||
| 67 | |||
| 68 | echo $html; |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @param array $data |
||
| 73 | * |
||
| 74 | * @return void |
||
| 75 | */ |
||
| 76 | public function error(array $data): void |
||
| 77 | { |
||
| 78 | $html = "Erro {$data['code']}"; |
||
| 79 | echo $html; |
||
| 80 | } |
||
| 81 | } |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.