{"id":16901946,"url":"https://github.com/barnabywalters/php-mf-cleaner","last_synced_at":"2025-03-22T10:30:59.236Z","repository":{"id":405144,"uuid":"10720654","full_name":"barnabywalters/php-mf-cleaner","owner":"barnabywalters","description":"Allows easy, reliable manipulation of canonical microformats 2 data structures.","archived":false,"fork":false,"pushed_at":"2022-11-15T20:09:38.000Z","size":518,"stargazers_count":12,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-15T07:39:24.375Z","etag":null,"topics":["indieweb","microformats","microformats2","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/barnabywalters.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-16T13:42:25.000Z","updated_at":"2024-06-19T18:40:33.000Z","dependencies_parsed_at":"2023-01-13T10:15:25.560Z","dependency_job_id":null,"html_url":"https://github.com/barnabywalters/php-mf-cleaner","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barnabywalters%2Fphp-mf-cleaner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barnabywalters%2Fphp-mf-cleaner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barnabywalters%2Fphp-mf-cleaner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barnabywalters%2Fphp-mf-cleaner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barnabywalters","download_url":"https://codeload.github.com/barnabywalters/php-mf-cleaner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244943683,"owners_count":20536279,"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","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":["indieweb","microformats","microformats2","php"],"created_at":"2024-10-13T18:02:56.196Z","updated_at":"2025-03-22T10:30:58.763Z","avatar_url":"https://github.com/barnabywalters.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-mf-cleaner\n\n[![Latest Stable Version](http://poser.pugx.org/barnabywalters/mf-cleaner/v)](https://packagist.org/packages/barnabywalters/mf-cleaner) \u003ca href=\"https://github.com/barnabywalters/mf-cleaner/actions/workflows/php.yml\"\u003e\u003cimg src=\"https://github.com/barnabywalters/php-mf-cleaner/actions/workflows/php.yml/badge.svg?branch=main\" alt=\"\" /\u003e\u003c/a\u003e [![License](http://poser.pugx.org/barnabywalters/mf-cleaner/license)](https://packagist.org/packages/barnabywalters/mf-cleaner) [![Total Downloads](http://poser.pugx.org/barnabywalters/mf-cleaner/downloads)](https://packagist.org/packages/barnabywalters/mf-cleaner) \n\nLots of little helpers for processing canonical [microformats2](http://microformats.org/wiki/microformats2) array structures. Counterpart to [indieweb/php-mf2](https://github.com/indieweb/php-mf2).\n\n## Installation\n\nbarnabywalters/mf-cleaner is currently tested against and compatible with PHP 7.3, 7.4, 8.0 and 8.1.\n\nInstall barnabywalters/mf-cleaner using [composer](https://getcomposer.org/):\n\n    composer.phar require barnabywalters/mf-cleaner\n    composer.phar install (or composer.phar update)\n\nVersioned releases are GPG signed so you can verify that the code hasn’t been tampered with.\n\n    gpg --recv-keys 1C00430B19C6B426922FE534BEF8CE58118AD524\n    cd vendor/barnabywalters/mf-cleaner\n    git tag -v v0.2.0 # Replace with the version you have installed\n\n## Usage\n\nMost of the functions are self explanatory, and all come with summaries in docblocks if something is unclear. This example shows the most common usage:\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n// Alias the namespace to ”Mf2” for convenience\nuse BarnabyWalters\\Mf2;\n\n// Check if an array structure is a microformat\n\n$hCard = [\n\t'type' =\u003e ['h-card'],\n\t'properties' =\u003e [\n\t\t'name' =\u003e ['Example McExampleface'],\n\t\t'photo' =\u003e [['value' =\u003e 'https://example.org/photo.png', 'alt' =\u003e 'a photo of an example']],\n\t\t'logo' =\u003e ['https://example.org/logo.png']\n\t]\n];\n\nMf2\\isMicroformat($hCard); // true\nMf2\\isMicroformat([1, 2, 3, 4, 'key' =\u003e 'value']); // false\n\nMf2\\hasProp($hCard, 'name'); // true\n\nMf2\\getPlaintext($hCard, 'name'); // 'Example McExampleface'\n\nMf2\\getPlaintext($hCard, 'photo'); // 'https://example.org/photo.png'\nMf2\\getImgAlt($hCard, 'photo'); // ['value' =\u003e 'https://example.org/photo.png', 'alt' =\u003e 'a photo of an example']\n\nMf2\\getImgAlt($hCard, 'logo'); // ['value' =\u003e 'https://example.org/logo.png', 'alt' =\u003e '']\n\n$hEntry = [\n\t'type' =\u003e ['h-entry'],\n\t'properties' =\u003e [\n\t\t'published' =\u003e ['2013-06-12 12:00:00'],\n\t\t'author' =\u003e [$hCard],\n\t\t'summary' =\u003e ['A plaintext summary with \u003c\u003e\u0026\" HTML special characters :o'],\n\t\t'content' =\u003e [['value' =\u003e 'Hi!', 'html' =\u003e '\u003cp\u003e\u003cem\u003eHi!\u003c/em\u003e\u003c/p\u003e']]\n\t]\n];\n\nMf2\\flattenMicroformats($hEntry); // returns array with $hEntry followed by $hCard\nMf2\\getAuthor($hEntry); // returns $hCard. Is an incomplete but still useful implementation of https://indieweb.org/authorship-spec which doesn’t follow links.\n\n// Get the published datetime, fall back to updated if that’s present check that\n// it can be parsed by \\DateTime, return null if it can’t be found or is invalid\nMf2\\getPublished($hEntry, true, null); // '2013-06-12 12:00:00'\n\nMf2\\getHtml($hEntry, 'content'); // '\u003cp\u003e\u003cem\u003eHi!\u003c/em\u003e\u003c/p\u003e'\nMf2\\getHtml($hEntry, 'summary'); // \"A plaintext summary with \u0026lt;\u0026gt;\u0026amp;\u0026quot; HTML special characters :o\"\n\n$microformats = [\n\t'items' =\u003e [$hEntry, $hCard]\n];\n\nMf2\\isMicroformatCollection($microformats); // true\n\nMf2\\findMicroformatsByType($microformats, 'h-card'); // [$hCard]\n\nMf2\\findMicroformatsByProperty($microformats, 'published'); // [$hEntry]\n\nMf2\\findMicroformatsByCallable($microformats, function ($mf) {\n\treturn Mf2\\hasProp($mf, 'published') and Mf2\\hasProp($mf, 'author');\n}); // [$hEntry]\n\n```\n\n## Contributing\n\nIf you have any questions about using this library, join the [indieweb dev chatroom](https://chat.indieweb.org/dev/), and ping `barnaby` or ask one of the other friendly people there.\n\nIf you find a bug or problem with the library, or want to suggest a feature, please [create an issue](https://github.com/barnabywalters/php-mf-cleaner/issues/new).\n\nIf discussions lead to you wanting to submit a pull request, following this process, while not required, will increase the chances of it quickly being accepted:\n\n* Fork this repo to your own github account, and clone it to your development computer.\n* Run `./run_coverage.sh` and ensure that all tests pass — you’ll need XDebug for code coverage data.\n* If applicable, write failing regression tests e.g. for a bug you’re fixing.\n* Make your changes.\n* Run `./run_coverage.sh` and `open docs/coverage/index.html`. Make sure that the changes you made are covered by tests. mf-cleaner had nearly 100% test coverage from early in its development, and that number should never go down!\n* Run `./vendor/bin/psalm` and and fix any warnings it brings up.\n* Install and run `./phpDocumentor.phar` to regenerate the documentation if applicable.\n* Push your changes and submit the PR.\n\n## Changelog\n\n### v0.2.0\n\n2022-11-15\n\n\u003e Awoken from their eight year long slumber, the maintainer lurched into activity to release a long-overdue update…\n\n**Breaking Changes:**\n\n* Raised minimum PHP version to 7.3\n* Renamed main branch from `master` to `main`. If you were requiring `dev-master` you will need to rename it to `dev-main`\n\nOther changes:\n\n* Added support for img-alt structures. `getPlaintext()` and `toPlaintext()` correctly return the `value` value. Added `isImgAlt()`, `toImgAlt()` and `getImgAlt()`, all of which do exactly what you’d expect them to.\n* Initial implementation of `removeFalsePositiveRootMicroformats()`, to restructure mf2 data into something usable when known non-mf2 h-* classnames are used\n* Added some more tests to improve coverage\n* Set up GH Action CI to test against PHP 7.3, 7.4, 8.0 and 8.1\n* Set up /docs with generated documentation (thanks HongPong!) and public code coverage info\n* getAuthor additionally looks for an h-feed author property (thanks aaronpk!)\n* Moved deeply nested Functions file to a shallower location for convenience\n* Started signing release tags to enable verification\n* Updated readme usage\n\n### v0.1.4\n2014-10-06\n\n* Improved getAuthor() algorithm, made non-standard portions optional\n* Added getRepresentativeHCard() function implementing http://microformats.org/wiki/representative-h-card-parsing\n\n### v0.1.3\n2014-05-16\n\n* Fixed issue causing getAuthor to return non-h-card microformats\n\n### v0.1.2\n\n### v0.1.1\n\n### v0.1.0\n* Initial version","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarnabywalters%2Fphp-mf-cleaner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarnabywalters%2Fphp-mf-cleaner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarnabywalters%2Fphp-mf-cleaner/lists"}