承接 digiaonline/common-sanitization-stages 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

digiaonline/common-sanitization-stages

最新稳定版本:1.2.0

Composer 安装命令:

composer require digiaonline/common-sanitization-stages

包简介

A collection of pipeline stages that are commonly needed when sanitizing data

README 文档

README

Build Status Coverage Status

A collection of pipeline stages that are commonly needed when sanitizing data

Requirements

  • PHP >= 7.1

Installation

composer require digiaonline/common-sanitization-stages

Usage

Let's say you're importing some legacy data into a new system. The original data is user generated content, so it cannot be trusted. Additionally, it contains some simple HTML that you want to strip. On top of all this, the legacy data must be possible to store in a CSV file, so you need to encode it somehow so the CSV delimiter is guaranteed not to occur in the text value.

To accomplish this, just combine the stages you need into a pipeline, then run the pipeline against your data:

<?php

require_once(__DIR__.'/vendor/autoload.php');

$rawInputData = <<<EOT
  The quick brown fox<br />
jumped over the <i>incredibly lazy dog</i> &amp; it
ran away.

EOT;

$encodedInputData = \base64_encode($rawInputData);

/** @var \League\Pipeline\Pipeline $pipeline */
$pipeline = (new \League\Pipeline\Pipeline())
    ->pipe(new \Digia\Sanitization\Stages\Base64DecodeStage())
    ->pipe(new \Digia\Sanitization\Stages\HtmlPurifierStage())
    ->pipe(new \Digia\Sanitization\Stages\HtmlEntityDecodeStage())
    ->pipe(new \Digia\Sanitization\Stages\StripLineFeedsStage(["\n"], true))
    ->pipe(new \Digia\Sanitization\Stages\TrimStringStage());

$outputData = $pipeline->process($encodedInputData);

var_dump($outputData); // string(70) "The quick brown fox jumped over the incredibly lazy dog & it ran away."

License

MIT

统计信息

  • 总下载量: 37.56k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 6
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固