{"id":30835516,"url":"https://github.com/mjkhajeh/wporm-extra-casts","last_synced_at":"2026-01-20T16:27:49.297Z","repository":{"id":312933639,"uuid":"1025734623","full_name":"mjkhajeh/wporm-extra-casts","owner":"mjkhajeh","description":"Extra type casts for WPORM models, providing advanced validation and sanitization using WordPress functions.","archived":false,"fork":false,"pushed_at":"2025-09-02T21:35:30.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-02T23:21:45.990Z","etag":null,"topics":["eloquent","orm","wordpress","wordpress-development","wordpress-plugin","wordpress-theme"],"latest_commit_sha":null,"homepage":"https://mjkhajeh.ir/","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/mjkhajeh.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-24T18:00:17.000Z","updated_at":"2025-09-02T21:37:37.000Z","dependencies_parsed_at":"2025-09-02T23:32:43.563Z","dependency_job_id":null,"html_url":"https://github.com/mjkhajeh/wporm-extra-casts","commit_stats":null,"previous_names":["mjkhajeh/wporm-extra-casts"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mjkhajeh/wporm-extra-casts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjkhajeh%2Fwporm-extra-casts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjkhajeh%2Fwporm-extra-casts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjkhajeh%2Fwporm-extra-casts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjkhajeh%2Fwporm-extra-casts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjkhajeh","download_url":"https://codeload.github.com/mjkhajeh/wporm-extra-casts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjkhajeh%2Fwporm-extra-casts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28607086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T16:10:39.856Z","status":"ssl_error","status_checked_at":"2026-01-20T16:10:39.493Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["eloquent","orm","wordpress","wordpress-development","wordpress-plugin","wordpress-theme"],"created_at":"2025-09-06T17:10:20.660Z","updated_at":"2026-01-20T16:27:49.292Z","avatar_url":"https://github.com/mjkhajeh.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WPORM Extra Casts\n\nExtra type casts for WPORM models, providing advanced validation and sanitization using WordPress functions.\n\n## Features\n- Seamless integration with WPORM\n- Uses WordPress native functions for sanitization and validation\n- Supports a wide range of data types\n- Extensible for custom data types\n\n## Requirements\n- PHP 7.4+\n- WordPress 5.0+\n- [WPORM](https://github.com/mjkhajeh/wporm) library\n\n## Installation\n\nInstall via Composer:\n\n```\ncomposer require mjkhajeh/wporm-extra-casts\n```\n\n## Supported Cast Types\n\n| Cast Type    | Description                                                                                 | WP Function Used           |\n|--------------|---------------------------------------------------------------------------------------------|---------------------------|\n| Date         | Normalizes date values to `Y-m-d` format                                                    | `date_i18n`, custom logic |\n| Time         | Normalizes time values to `H:i:s` format                                                    | `date_i18n`, custom logic |\n| Serialized   | Handles PHP serialized data                                                                 | `maybe_serialize`, `maybe_unserialize` |\n| Slug         | Converts strings to URL-friendly slugs                                                       | `sanitize_title`          |\n| Email        | Validates and normalizes email addresses                                                    | `sanitize_email`          |\n| URL          | Validates and normalizes URLs                                                               | `esc_url_raw`             |\n| FilePath     | Sanitizes and normalizes file paths                                                         | `sanitize_file_name`      |\n| PostID       | Ensures values are valid WordPress post IDs                                                 | `absint`                  |\n| UserID       | Ensures values are valid WordPress user IDs                                                 | `absint`                  |\n| CustomEnum   | Restricts values to a defined set, with sanitization                                        | `sanitize_text_field`     |\n| Base64       | Handles base64 encoding/decoding                                                            | `base64_encode`, `base64_decode` |\n| Mobile       | Validates and normalizes mobile phone numbers                                               | `sanitize_text_field`     |\n\n## Usage\n\nAdd the desired cast to your WPORM model’s `$casts` property. Example:\n\n```php\nuse MJ\\WPROM\\ExtraCasts\\Date;\nuse MJ\\WPROM\\ExtraCasts\\Slug;\n\nclass MyModel extends Model {\n    protected $casts = [\n        'published_at' =\u003e Date::class,\n        'post_slug'    =\u003e Slug::class,\n    ];\n}\n```\n\n## CustomEnum Example\n\n`CustomEnum` allows you to restrict a field to a set of allowed values, with WordPress sanitization:\n\n```php\nuse MJ\\WPROM\\ExtraCasts\\CustomEnum;\n\n// Define allowed values\n$enum = new CustomEnum(['draft', 'pending', 'published']);\n\n// Getting a value\n$value = $enum-\u003eget('published'); // returns 'published'\n$value = $enum-\u003eget('trash');     // returns null\n\n// Setting a value\n$set = $enum-\u003eset('pending');     // returns 'pending'\n$set = $enum-\u003eset('unknown');     // returns null\n```\n\nYou can use `CustomEnum` in your model like this:\n\n```php\nclass Post extends Model {\n    protected $casts = [\n        'status' =\u003e [CustomEnum::class, ['draft', 'pending', 'published']]\n    ];\n}\n```\n\n## License\n\nMIT License © MohammadJafar Khajeh\n\n## Author\n\nMohammadJafar Khajeh\n[mjkhajehg@gmail.com](mailto:mjkhajehg@gmail.com)\n\n## Links\n- [WPORM](https://github.com/mjkhajeh/wporm)\n- [WordPress Developer Resources](https://developer.wordpress.org/reference/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjkhajeh%2Fwporm-extra-casts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjkhajeh%2Fwporm-extra-casts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjkhajeh%2Fwporm-extra-casts/lists"}