jakub-the-developer / php-frame
Draw ascii frame around lines of text.
v1.1
2021-07-16 08:37 UTC
Requires
- php: ^7.4||^8.0
Requires (Dev)
- phpunit/phpunit: ^9.5
README
About
PHP library for drawing a frame around lines of text.
Installation
Requirements
To install this package you have to use composer 2
.
Install
composer require jakub-the-developer/php-frame
Usage
<?php require './vendor/autoload.php'; use JakubTheDeveloper\PhpFrame\Frame; $frame = new Frame( [ "First line of the text", "Second line of the text", "© Copyright information", ] ); echo $frame->draw();
Examples
Default configuration
$frame = new \JakubTheDeveloper\PhpFrame\Frame( [ "First line of the text", "Second line of the text", "© Copyright information", ] ); echo $frame->draw();
Result:
╔═══════════════════════════════════════╗ ║ ║ ║ ║ ║ First line of the text ║ ║ Second line of the text ║ ║ © Copyright information ║ ║ ║ ║ ║ ╚═══════════════════════════════════════╝
Screenshot:
Custom configuration
$configuration = new \JakubTheDeveloper\PhpFrame\FrameConfiguration( 1, // top margin lines 3, // bottom margin lines 26, // margin left 26, // margin right '+', // top-left corner symbol '+', // top-right corner symbol '+', // top-left corner symbol '+', // top-left corner symbol '~', // horizontal border symbol '|' // vertical border symbol ); $frame = new \JakubTheDeveloper\PhpFrame\Frame( [ "First, longer line of the text", "Second line", "And the third", ], $configuration );
Result:
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ | | | First, longer line of the text | | Second line | | And the third | | | | | | | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
Screenshot:
Run tests
./vendor/bin/phpunit
with code coverage (html):
./vendor/bin/phpunit --coverage-html coverage