sadovnik / ph
Heredoc alternative for text.
1.0.0
2016-12-05 09:12 UTC
Requires
- php: >=5.6
Requires (Dev)
- codeclimate/php-test-reporter: ^0.3.2
- phpunit/phpunit: ~5.3
- squizlabs/php_codesniffer: ~2.6
This package is not auto-updated.
Last update: 2024-11-04 14:48:56 UTC
README
It's painful to write heredocs in the middle of some indentation level:
class CliApp { public static function printUsage() { echo <<<EOL Usage: linter [--fix] [--debug] <path> linter (-h | --help) linter --version EOL; } }
Ruby has smart heredocs that respect indentation:
class CliApp def self.print_usage puts <<~EOL Usage: linter [--fix] [--debug] <path> linter (-h | --help) linter --version EOL end end
But PHP has not.
So I made a basic function that receives string and strips it:
use function Sadovnik\PrettyHeredoc\ph as ✍️; class CliApp { public static function printUsage() { echo ✍️(' Usage: linter [--fix] [--debug] <path> linter (-h | --help) linter --version '); } }
Enjoy it!
Install
Via Composer:
composer require sadovnik/ph
⚓️