{"id":22477550,"url":"https://github.com/maplephp/dto","last_synced_at":"2025-08-02T13:31:07.499Z","repository":{"id":209843897,"uuid":"662085524","full_name":"MaplePHP/DTO","owner":"MaplePHP","description":"Data transfer object","archived":false,"fork":false,"pushed_at":"2024-10-02T15:40:05.000Z","size":547,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-10T19:22:29.906Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/MaplePHP.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":"2023-07-04T10:19:41.000Z","updated_at":"2024-10-02T15:17:53.000Z","dependencies_parsed_at":"2023-12-08T13:28:26.499Z","dependency_job_id":"0b333045-33d7-4c7c-accf-281d65241e4e","html_url":"https://github.com/MaplePHP/DTO","commit_stats":null,"previous_names":["maplephp/dto"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaplePHP%2FDTO","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaplePHP%2FDTO/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaplePHP%2FDTO/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaplePHP%2FDTO/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaplePHP","download_url":"https://codeload.github.com/MaplePHP/DTO/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228476038,"owners_count":17926134,"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-12-06T14:11:30.999Z","updated_at":"2025-08-02T13:31:07.488Z","avatar_url":"https://github.com/MaplePHP.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Darn Tidy Object (DTO)\n\nDTO stands for **Darn Tidy Object**, a playful twist on the traditional Data Transfer Object. But this isn’t your average DTO. It’s a fully-loaded toolkit for **traversing, transforming, and tidying up structured data** in PHP with style, power, and simplicity.\n\n\n## 📦 Installation\n\n```bash\ncomposer require maplephp/dto\n```\n\n## 📘 Documentation\n- [Why DTO?](https://maplephp.github.io/DTO/docs/intro#why-dto)\n- [Traverse Collection](https://maplephp.github.io/DTO/docs/traverse)\n- [Format string](https://maplephp.github.io/DTO/docs/format-string)\n- [Format Number](https://maplephp.github.io/DTO/docs/format-number)\n- [Format Clock](https://maplephp.github.io/DTO/docs/format-clock)\n- [Format Dom](https://maplephp.github.io/DTO/docs/format-dom)\n\n\n## How It Works\n\nDTO wraps your data arrays into a powerful, fluent object structure. Instead of cluttered array access, your code becomes expressive and self-documenting.\n\n### Before DTO\n\n```php\n$name = isset($data['user']['profile']['name'])\n    ? ucfirst(strip_tags($data['user']['profile']['name']))\n    : 'Guest';\n```\n\n### With DTO\n\n```php\n$name = $obj-\u003euser-\u003eprofile-\u003ename\n    -\u003estrStripTags()\n    -\u003estrUcFirst()\n    -\u003efallback('Guest')\n    -\u003eget();\n```\n\nMuch tidier, right?\n\n---\n\n## ✨ Core Features\n\n### Smart Data Traversal\n\nAccess deeply nested data without ever worrying about undefined keys.\n\n```php\necho $obj-\u003earticle-\u003etagline-\u003estrToUpper();  \n// Result: 'HELLO WORLD'\n\necho $obj-\u003earticle-\u003econtent-\u003estrExcerpt()-\u003estrUcFirst();  \n// Result: 'Lorem ipsum dolor sit amet...'\n```\n\n---\n\n### Built-In Data Transformation\n\nTransform values directly using built-in helpers like:\n\n#### Strings (`str`)\n\n```php\necho $obj-\u003etitle-\u003estrSlug();  \n// Result: 'my-awesome-title'\n```\n\n#### Numbers (`num`)\n\n```php\necho $obj-\u003efilesize-\u003enumToFilesize();  \n// Result: '1.95 kb'\n\necho $obj-\u003eprice-\u003enumRound(2)-\u003enumToCurrency(\"USD\");  \n// Result: $1,999.99\n```\n\n#### Dates (`clock`)\n\n```php\necho $obj-\u003ecreated_at-\u003eclockFormat('d M, Y', 'sv_SE');  \n// Result: '21 augusti 2025'\n\necho $obj-\u003ecreated_at-\u003eclockIsToday();  \n// Result: true\n```\n\n#### HTML DOM Builder (`dom`)\n\n```php\necho $obj-\u003eheading-\u003edomTag(\"h1.title\");  \n// Result: \u003ch1 class=\"title\"\u003eMy Heading\u003c/h1\u003e\n```\n\nOr nest elements with ease:\n\n```php\necho $obj-\u003etitle-\u003edomTag(\"h1.title\")-\u003edomTag(\"header\");  \n// Result: \u003cheader\u003e\u003ch1 class=\"title\"\u003eHello\u003c/h1\u003e\u003c/header\u003e\n```\n\n---\n\n### Built-In Collection Support\n\nWork with arrays of objects just as cleanly:\n\n```php\nforeach ($obj-\u003eusers-\u003efetch() as $user) {\n    echo $user-\u003efirstName-\u003estrUcFirst();\n}\n```\n\n---\n\n### Modify Data on the Fly\n\nChange values directly without verbose conditionals:\n\n```php\n$updated = $obj-\u003eshoppingList-\u003ereplace([0 =\u003e 'Shampoo']);\nprint_r($updated-\u003etoArray());\n```\n\n---\n\nNow go forth, write cleaner code, and let DTO handle the messy parts.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaplephp%2Fdto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaplephp%2Fdto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaplephp%2Fdto/lists"}