hnrazevedo / filter
Filter is a simple component to check information.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Requires
- php: >=7.4
This package is auto-updated.
Last update: 2020-09-22 20:27:00 UTC
README
Filter is a simple component to check information. Its author is not a professional in the development area, just someone from the Technology area who is improving his knowledge
O Filter é um simples componente para checar alguma informação. Seu autor não é profissional da área de desenvolvimento, apenas alguem da área de Tecnologia que está aperfeiçoando seus conhecimentos.
Update
I will soon update the project in order to implement the PSR.
Em breve atualizarei o projeto a fim de implementar a PSR.
Highlights
- Easy to set up (Fácil de configurar)
- Composer ready (Pronto para o composer)
Installation
Filter is available via Composer:
"hnrazevedo/filter": "^1.0"
or run
composer require hnrazevedo/filter
Documentation
For details on how to use the Filter, see the sample folder with details in the component directory
Para mais detalhes sobre como usar o Filter, veja a pasta de exemplos com detalhes no diretório do componente
Filter methods
/* Check the filter */ $filter->check($filter_name); /* Returns a string with an error message in case of false return in the check */ $filter->getMessage($filter_name);
Basic use
if(!$filter->check('user_in')){ echo $filter->getMessage('user_in'); }
Filter definition
use HnrAzevedo\Filter\Filter; class User extends Filter{ public function user_in(): bool { /* Set message to be displayed in case of error */ $this->addMessage('user_in','User required to be logged in.'); /* OPTIONAL: Defines function to be executed before the error is returned to the client */ $this->addTreat('user_in','report_notLogged'); /* Test something and return your result */ return (array_key_exists('user',$_SESSION)); } public function report_notLogged(): void { /* Do something before the error is returned to the client */ } /* Other filters and treatments ... */ }
Errors
If the filter does not return a Boolean the check will be false, refusing any request
Caso o filtro não retorne um boleano a checagem retornara falsa, recusando qualquer requisição
Support
Security: If you discover any security related issues, please email hnrazevedo@gmail.com instead of using the issue tracker.
Se você descobrir algum problema relacionado à segurança, envie um e-mail para hnrazevedo@gmail.com em vez de usar o rastreador de problemas.
Credits
- Henri Azevedo (Developer)
License
The MIT License (MIT). Please see License File for more information.