{"id":19302071,"url":"https://github.com/codespede/property-preprocessor","last_synced_at":"2026-04-17T14:37:26.197Z","repository":{"id":147273173,"uuid":"150974184","full_name":"codespede/property-preprocessor","owner":"codespede","description":"This is a simple trait which allows one to easily pre-process the properties before they are returned, in classes which use it","archived":false,"fork":false,"pushed_at":"2018-11-02T05:01:20.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-05T23:12:26.966Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codespede.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-30T14:26:35.000Z","updated_at":"2018-10-21T13:41:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"92eb57ba-6ad5-4d8c-b85b-93f057ca4e40","html_url":"https://github.com/codespede/property-preprocessor","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codespede%2Fproperty-preprocessor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codespede%2Fproperty-preprocessor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codespede%2Fproperty-preprocessor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codespede%2Fproperty-preprocessor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codespede","download_url":"https://codeload.github.com/codespede/property-preprocessor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240404337,"owners_count":19796056,"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":[],"created_at":"2024-11-09T23:19:49.663Z","updated_at":"2025-11-16T14:04:34.042Z","avatar_url":"https://github.com/codespede.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Property Value Pre-processor for PHP\nThis is a simple yet powerful trait which allows one to easily pre-process the properties before they are returned from the objects of classes which use it.\n\nInstallation\n------------\nThe preferred way to install this extension is to [click here](https://github.com/codespede/property-preprocessor/archive/master.zip) which will download the package as a zip file. Instructions on how to use it is explained below.\n\nHow to use\n----------\nFrom the downloaded zip, place the file PreProcessorTrait.php in your project's 'traits' folder(please create one if it does not exist). In your classes, you can use the trait as below:\n```\nclass ClassName{\nuse \\traits\\PreProcessorTrait.php\n...\n...\n...\n}\n```\n\nUse Cases\n---------\nSuppose you have an object `$store` and it has a property `$products` which is an array of all the `Product` objects in that `Store`.\n\nThe `Product` objects are too large and it contains lot of data and you currently need only some minimal data.\n\nUse `PreProcessorTrait` in the `$store` object's class as explained above and insert the following method in `traits\\PreProcessorTrait.php`\n```\npublic function getMinified($objects){\n\t\tforeach($objects as \u0026$object){\n\t\t\t  $object-\u003eminify();\n\t\t}\n\t\treturn $objects;\n}\n\npublic function minify(){\n    //your logic to minify and return the object\n}\n```\nYou can get the minified data by calling like this: `$store-\u003eproductsMinified`. Similarly you can use like this for any property of the $store object. Eg:- `$store-\u003einvoicesMinified`, `$store-\u003ecustomersMinified` etc.\n\nFrom this point on, any class using the `PreProcessorTrait` will have the ability to minify it's properties before returning them.\n\nFor example:\n```\n$customer-\u003eordersMinified\n$brand-\u003eproductsMinified\n$product-\u003ecategoriesMinified\n```\n\nLike this, you can add whatever methods in PreProcessorTrait and it can be used in any object in which this trait is used in the very same way explained above. For more use cases and examples, [click here](https://github.com/codespede/property-preprocessor/blob/master/EXAMPLES.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodespede%2Fproperty-preprocessor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodespede%2Fproperty-preprocessor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodespede%2Fproperty-preprocessor/lists"}