{"id":22656860,"url":"https://github.com/libreworks/caridea-filter","last_synced_at":"2025-07-29T02:04:22.710Z","repository":{"id":62499619,"uuid":"68251794","full_name":"libreworks/caridea-filter","owner":"libreworks","description":":fried_shrimp: Caridea is a miniscule PHP application library. This is a shrimpy value sanitation library.","archived":false,"fork":false,"pushed_at":"2018-01-20T20:55:12.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-29T02:02:49.929Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libreworks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-14T23:32:57.000Z","updated_at":"2016-11-17T19:50:13.000Z","dependencies_parsed_at":"2022-11-02T11:47:09.947Z","dependency_job_id":null,"html_url":"https://github.com/libreworks/caridea-filter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/libreworks/caridea-filter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fcaridea-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fcaridea-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fcaridea-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fcaridea-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libreworks","download_url":"https://codeload.github.com/libreworks/caridea-filter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fcaridea-filter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267617636,"owners_count":24116207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-09T10:16:43.138Z","updated_at":"2025-07-29T02:04:22.688Z","avatar_url":"https://github.com/libreworks.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# caridea-filter\nCaridea is a miniscule PHP application library. This shrimpy fellow is what you'd use when you just want some helping hands and not a full-blown framework.\n\n![](http://libreworks.com/caridea-100.png)\n\nThis is its value sanitation library.\n\n[![Packagist](https://img.shields.io/packagist/v/caridea/filter.svg)](https://packagist.org/packages/caridea/filter)\n[![Build Status](https://travis-ci.org/libreworks/caridea-filter.svg)](https://travis-ci.org/libreworks/caridea-filter)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/libreworks/caridea-filter/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/libreworks/caridea-filter/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/libreworks/caridea-filter/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/libreworks/caridea-filter/?branch=master)\n[![Documentation Status](http://readthedocs.org/projects/caridea-filter/badge/?version=latest)](http://caridea-filter.readthedocs.io/en/latest/?badge=latest)\n\n## Installation\n\nYou can install this library using Composer:\n\n```console\n$ composer require caridea/filter\n```\n\n* The master branch (version 3.x) of this project requires PHP 7.1 and the `mbstring` extension.\n* Version 2.x of this project requires PHP 7.0 and the `mbstring` extension.\n\n## Compliance\n\nReleases of this library will conform to [Semantic Versioning](http://semver.org).\n\nOur code is intended to comply with [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/), and [PSR-4](http://www.php-fig.org/psr/psr-4/). If you find any issues related to standards compliance, please send a pull request!\n\n## Documentation\n\n* Head over to [Read the Docs](http://caridea-filter.readthedocs.io/en/latest/)\n\n## Examples\n\nJust a few quick examples. Let's define a set of filters for a person record.\n\n```php\n// let's pretend this came from $_POST\n$input = [\n    'name' =\u003e 'john smith  ',\n    'birthday' =\u003e '1990-01-01__',\n    'bio' =\u003e \"Mistakenly written on Windows\\r\\nThat's a problem.  \",\n    'friends' =\u003e 'Jane'\n];\n\n$registry = new \\Caridea\\Filter\\Registry(); // you can register your own filters if you choose\n$b = $registry-\u003ebuilder();\n$b-\u003ealways('name')-\u003ethen('trim')-\u003ethen('titlecase'); // always() will run chain even if missing from input\n$b-\u003efield('birthday')-\u003ethen('regex', '/[^0-9-]/', '');\n$b-\u003efield('bio')-\u003ethen('trim')-\u003ethen('nl'); // convert to UNIX newlines\n$b-\u003ealways('species')-\u003ethen('default', 'Homo sapiens');\n$b-\u003efield('friends')-\u003ethen('array')-\u003eeach('trim'); // each() will run the filter on every element\n// by default, all fields you don't specify are dropped.\n// but! otherwise() can specify a fallback chain for any non-declared fields.\n// $b-\u003eotherwise('trim')-\u003ethen('default', null);\n$filter = $b-\u003ebuild();\n$output = $filter($input);\nvar_dump($output);\n```\n```\narray(5) {\n  'name' =\u003e\n  string(10) \"John Smith\"\n  'birthday' =\u003e\n  string(10) \"1990-01-01\"\n  'bio' =\u003e\n  string(47) \"Mistakenly written on Windows\nThat's a problem.\"\n  'species' =\u003e\n  string(12) \"Homo sapiens\"\n  'friends' =\u003e\n  array(1) {\n    [0] =\u003e\n    string(4) \"Jane\"\n  }\n}\n```\n\nYou can also supply one or more `Reducer`s which are intended to combine and rewrite multiple values at once.\n\n```php\n// let's pretend this came from $_POST\n$input = [\n    'username' =\u003e '  doublecompile  ',\n    'id-0' =\u003e '1',\n    'id-5' =\u003e '4',\n    'id-1' =\u003e '9'\n];\n\n$registry = new \\Caridea\\Filter\\Registry();\n$b = $registry-\u003ebuilder();\n$b-\u003ealways('username')-\u003ethen('trim');\n$b-\u003ereducer(Combiners::appender('ids', 'id-'));\n$filter = $b-\u003ebuild();\n$output = $filter($input);\nvar_dump($output);\n```\n```\narray(2) {\n  'username' =\u003e\n  string(13) \"doublecompile\"\n  'ids' =\u003e\n  array(3) {\n    [0] =\u003e\n    string(1) \"1\"\n    [1] =\u003e\n    string(1) \"4\"\n    [2] =\u003e\n    string(1) \"9\"\n  }\n}\n```\nThe `Filter` class itself is a `Reducer`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibreworks%2Fcaridea-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibreworks%2Fcaridea-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibreworks%2Fcaridea-filter/lists"}