sitedyno/irc格式剥离器

从字符串中移除irc格式化程序

v1.0.1 2016-12-25 23:45 UTC

This package is auto-updated.

Last update: 2024-09-06 09:12:33 UTC


README

Build Status codecov

用于从字符串中移除IRC格式代码的库。

安装

推荐的安装方法是通过composer

php composer.phar require sitedyno/irc-format-stripper

配置

目前没有配置。

使用示例

use Sitedyno\Irc\Format\Stripper;

$stripper = new Stripper;
$testMessage = "\x0301This text is black in IRC";
echo $testMessage;
// Outputs: 01This text is black in IRC
$strippedMessage = $stripper->strip($testMessage);
echo $strippedMessage;
// Outputs: This text is black in IRC

Monolog处理器示例

use Sitedyno\Irc\Format\Stripper;

$stripper = new Stripper;
$testMessage = "\x0301This text is black in IRC";
echo $testMessage;
// Outputs: 01This text is black in IRC
$streamHandler = new \Monolog\Handler\StreamHandler(
    'mylog.log',
    \Monolog\Logger::DEBUG
);
$logger = new \Monolog\Logger(
    'mylog',
    [$streamHandler]
);
$logger->pushProcessor(function($record) use ($stripper) {
    $record['message'] = $stripper->strip($record['message']);
    return $record;
});
$logger->info($testMessage);
// Outputs to mylog.log: [2016-12-25 22:00:52] mylog.INFO This text is black in IRC

测试

要运行单元测试套件

curl -s https://getcomposer.org/installer | php
php composer.phar install
./vendor/bin/phpunit

许可证

在MIT许可证下发布。请参阅LICENSE.md