๐Ÿ“ฆ shieldfy / sniffer

sniff inputs type

โ˜… 10 stars โ‘‚ 1 forks ๐Ÿ‘ 10 watching โš–๏ธ MIT License
๐Ÿ“ฅ Clone https://github.com/shieldfy/sniffer.git
HTTPS git clone https://github.com/shieldfy/sniffer.git
SSH git clone git@github.com:shieldfy/sniffer.git
CLI gh repo clone shieldfy/sniffer
Eslam Salem Eslam Salem change travis config e12f879 8 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ src
๐Ÿ“„ .gitignore
๐Ÿ“„ .travis.yml
๐Ÿ“„ composer.json
๐Ÿ“„ LICENSE
๐Ÿ“„ phpunit.xml
๐Ÿ“„ README.md
๐Ÿ“„ README.md

Shieldfy Sniffer

Shieldfy Sniffer is a small composer package to detect the input type , now support 4 types ( integer , string , json , serialize)

Packagist License Code Climate Travis

Installation

Through Composer

composer require shieldfy/sniffer

Usage & Examples

$type = (new \Shieldfy\Sniffer\Sniffer)->sniff('12.5'); //number

$type = (new \Shieldfy\Sniffer\Sniffer)->sniff('hello world'); //string

$type = (new \Shieldfy\Sniffer\Sniffer)->sniff(json_encode(['hello'=>1,'world'=>'!'])); //json

$type = (new \Shieldfy\Sniffer\Sniffer)->sniff(serialize(['hello'=>1,'world'=>'!'])); //serialize

//you can add more than value as array
$type = (new \Shieldfy\Sniffer\Sniffer)->sniff(['555','abc']);

//test against particular type
$result = (new \Shieldfy\Sniffer\Sniffer)->is('123456789','number'); //true

//you can register your own sniffer on the runtime
$type = (new \Shieldfy\Sniffer\Sniffer)->register('hello',function($input){
	if(strstr($input,'hello')) 
		return true;
	return false;
})->sniff('say hello world');

note about serialization

Serialize / Unserialize can be danger due to its ability to convert object and it can be used to preform object injection attack. So explicit sniffing not allowed in php version before php 7 thats because php7 offered new options to prevent object serialization see here

Contributing

Thank you for considering contributing to this project! Bug reports, feature requests, and pull requests are very welcome.

Security Vulnerabilities

If you discover a security vulnerability within this project, please send an e-mail to security@shieldfy.com.