PHPackages                             dbx12/data-censor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dbx12/data-censor

ActiveProject[Utility &amp; Helpers](/categories/utility)

dbx12/data-censor
=================

A tool to quickly censor data structures and JSON files before publishing them.

v1.0(5y ago)07MITPHP

Since Feb 19Pushed 5y ago1 watchersCompare

[ Source](https://github.com/DBX12/data-censor)[ Packagist](https://packagist.org/packages/dbx12/data-censor)[ RSS](/packages/dbx12-data-censor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Data censor
===========

[](#data-censor)

A simple tool to censor data structures.

Motivation
----------

[](#motivation)

When documenting software, you often have to deal with data structures used in examples. Maybe an API response or request data. This data often contains sensitive information like API tokens, usernames or other personal information. Hunting these entries is tedious and should be automated, right?

Usage
-----

[](#usage)

Create a `\dbx12\jsonCensor\Censor` object, call `addRule()` on it for every key you want to censor and finally send your data into `censor()` or let Censor read it from a file and write it to another file.

A more thorough example is in `example.php`

### Paths

[](#paths)

A path describes an element in your input data, a bit like a CSS selector does. Every path must start with a `.` and end in a property name. In the example JSON below, you would address the field containing "john" with `.users.name`. Note how the index in the users list is unspecified. There are no numeric indices in these path descriptions. You can specify multiple paths which are subject to the same rule as array. Using `['.users.name','.users.email']` as first parameter to `addRule()` and `['role' => 'Admin']` as second would remove the name and email for all admins.

### Conditions

[](#conditions)

A condition defines if the rule applies to that element. You can use the siblings of the selected element to decide that. You define a condition as array structure, the key describes the field, the value describes what value(s) is expected. You can use an array to define multiple allowed values. Multiple keys can be checked (all must match then).

Assume we selected `.users.name` in the example below and want to remove it if it belongs to a Customer or Subscriber. The rule would be: `['role' => ['Customer','Subscriber']]`.

### Example JSON

[](#example-json)

```
{
  "users": [
    {
      "name": "john",
      "role": "Admin",
      "email": "john.doe@example.org",
      "moneySpent": 0
    },
    {
      "name": "jane",
      "role": "Customer",
      "email": "jane.doe@example.org",
      "moneySpent": 100
    },
    {
      "name": "alex",
      "role": "Subscriber",
      "email": "alex.doe@example.org",
      "moneySpent": 0
    }
  ],
  "purchases": [
    {
      "customerName": "jane",
      "items": {
        "apple": 5,
        "banana": 2
      }
    }
  ]
}
```

### Strategies

[](#strategies)

The strategy defines how the value (or key and value in case of an array) are censored. All strategies must implement the `CensorStrategyInterface`. If no strategy is specified for a rule, the `ConstantCensorStrategy` is used. This can be changed by modifying `Censor::$defaultStrategy`.

You can easily extend the functionality of this project by defining own censor strategies. Simply implement the `\dbx12\jsonCensor\censorStrategies\CensorStrategyInterface` with your censor logic.

Known limitations
-----------------

[](#known-limitations)

The system works only with scalar values (e.g. string, int) and arrays (both, numeric and associative). The behavior on encountering something else (e.g. ressource or object instances) is undefined and most likely a crash.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1913d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7dd9e7c6d0c101b23d35ddde728a50a7263b43f2103416c3022cb5f6ca0fa7ab?d=identicon)[DBX12](/maintainers/DBX12)

---

Top Contributors

[![DBX12](https://avatars.githubusercontent.com/u/6484542?v=4)](https://github.com/DBX12 "DBX12 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dbx12-data-censor/health.svg)

```
[![Health](https://phpackages.com/badges/dbx12-data-censor/health.svg)](https://phpackages.com/packages/dbx12-data-censor)
```

###  Alternatives

[otgs/multilingual-tools

Set of tools related to WPML plugin bundle. Created with tendency to ease WPML compatibility testing process.

39165.9k](/packages/otgs-multilingual-tools)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
