for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace HnrAzevedo\Router;
use HnrAzevedo\Validator\Validator;
trait Helper{
use CheckTrait;
protected function getProtocol(): string
{
if((isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')){
return 'ajax';
}
/* ONLY FOR DEBUG CONDITION */
if(!array_key_exists('REQUEST_METHOD',$_SERVER)){
return 'get';
return strtolower($_SERVER['REQUEST_METHOD']);
protected function getData(): ?array
return [
'POST' => $_POST,
'GET' => $_GET,
'FILES' => $_FILES
];
protected function import(string $path)
foreach (scandir($path) as $routeFile) {
if(pathinfo($path.DIRECTORY_SEPARATOR.$routeFile, PATHINFO_EXTENSION) === 'php'){
require_once($path. DIRECTORY_SEPARATOR .$routeFile);
protected function ControllerForm($controller, string $method, array $values){
if(Validator::execute($values)){
$this->check_role();
$role = ($method !== 'method') ? $method : $this->getData()['POST']['role'];
$data = (!is_null($values)) ? json_decode($values['data']) : null;
is_null($values)
false
$controller->$role($data);