linio / safeecho
Lightweight function to easily hide printed data.
Requires
- php: >=7.1
- hassankhan/config: ^0.10.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- phpunit/phpunit: ^6.0
This package is auto-updated.
Last update: 2024-10-28 19:23:55 UTC
README
Purpose
Replacement function for echo/print. It will take the string, hide it and then wrap the new hidden string with whatever wrapper is specified.
echo John Smith
will print John Smith
Out-of-the-box
safeecho('John Smith')
will print J*** S****
With a configuration file
safeecho('John Smith')
can print
<span style="cursor: pointer;" onmouseout="this.innerHTML='J*** S****'" onmouseover="this.innerHTML='John Smith'">J*** S****</span>
Installation
The supported way of installing safeecho is via Composer.
$ composer require linio/safeecho
Autoload function
In the composer.json
file, add or append to the "autoload" field,
"autoload": {
"files": [
"vendor/linio/safeecho/src/safeecho.php"
]
}
Configure safeecho Output
To override the default configuration of safeecho
, you will need a configuration file.
Accepted file names are:
safeecho.ini
safeecho.json
safeecho.php
safeecho.xml
safeecho.yaml
safeecho.yml
Configuration files are searched for in the above order. The first configuration file found, is the configuration that is used.
The recommended location for the configuration is the project root directory.
Example YML Configurations
safeecho.yml
decorator: Linio\SafeEcho\Decorator\MouseHoverDecorator
If you want to change the 'hideChar'
safeecho.yml
decorator: Linio\SafeEcho\Decorator\MouseHoverDecorator
hideChar: '~'
safeecho('John Smith')
will now print
<span style="cursor: pointer;" onmouseout="this.innerHTML='J~~~ S~~~~'" onmouseover="this.innerHTML='John Smith'">J~~~ S~~~~</span>
To use your own custom Decorator:
YourCustomDecorator
must extendSafeEchoDecorator
safeecho.yml
decorator:
class: \Path\To\YourCustomDecorator
arguments:
arg1: arg1Value
arg2: arg2Value
Please see safeecho Configuration File for configuration file examples.
Testing
$ vendor/bin/phpunit
License
The MIT License (MIT). Please see License File for more information.