{"id":18794577,"url":"https://github.com/effectra/to-string","last_synced_at":"2026-02-06T00:31:13.642Z","repository":{"id":164792794,"uuid":"640218783","full_name":"effectra/to-string","owner":"effectra","description":"Convert any type of data to string","archived":false,"fork":false,"pushed_at":"2024-12-06T10:20:29.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-22T13:26:08.582Z","etag":null,"topics":["php","string-formatter","string-manipulation","text-processing"],"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/effectra.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-13T11:20:56.000Z","updated_at":"2024-12-06T10:18:31.000Z","dependencies_parsed_at":"2023-12-01T21:31:40.606Z","dependency_job_id":"60a3fa0d-a9e9-4e5d-a809-483955431bb4","html_url":"https://github.com/effectra/to-string","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/effectra/to-string","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fto-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fto-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fto-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fto-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/effectra","download_url":"https://codeload.github.com/effectra/to-string/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fto-string/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29140115,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T23:14:48.546Z","status":"ssl_error","status_checked_at":"2026-02-05T23:14:35.724Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["php","string-formatter","string-manipulation","text-processing"],"created_at":"2024-11-07T21:29:50.620Z","updated_at":"2026-02-06T00:31:13.621Z","avatar_url":"https://github.com/effectra.png","language":"PHP","readme":"# to-string PHP Library\n\n`to-string` is a PHP library that provides various utility classes for string manipulation and conversion. It offers functionality to convert text case, strip tags, generate slugs, format arrays, and handle date/time values.\n\n## Installation\n\nYou can install the `to-string` library via Composer. Run the following command in your project directory:\n\n```\ncomposer require effectra/to-string\n```\n\n## Usage\n\n### TextToString\n\n#### `toUppercase(string $text): string`\n\nConverts a string to uppercase.\n\n```php\nuse Effectra\\ToString\\TextToString;\n\n$textToString = new TextToString();\n$result = $textToString-\u003etoUppercase('Hello, World!');\necho $result; // Output: HELLO, WORLD!\n```\n\n#### `toLowercase(string $text): string`\n\nConverts a string to lowercase.\n\n```php\nuse Effectra\\ToString\\TextToString;\n\n$textToString = new TextToString();\n$result = $textToString-\u003etoLowercase('Hello, World!');\necho $result; // Output: hello, world!\n```\n\n#### `strip(string $text): string`\n\nStrips HTML and PHP tags from a string.\n\n```php\nuse Effectra\\ToString\\TextToString;\n\n$textToString = new TextToString();\n$result = $textToString-\u003estrip('\u003cp\u003eHello, \u003cb\u003eWorld!\u003c/b\u003e\u003c/p\u003e');\necho $result; // Output: Hello, World!\n```\n\n#### `nameVar($variable): string`\n\nExtracts the variable name from the caller's context.\n\n```php\nuse Effectra\\ToString\\TextToString;\n\n$textToString = new TextToString();\n$myVariable = 'Hello, World!';\n$result = $textToString-\u003enameVar($myVariable);\necho $result; // Output: myVariable\n```\n\n#### `textToSlug($text): string`\n\nConverts a string to a URL-friendly slug.\n\n```php\nuse Effectra\\ToString\\TextToString;\n\n$textToString = new TextToString();\n$result = $textToString-\u003etextToSlug('Hello, World!');\necho $result; // Output: hello-world\n```\n\n#### `slugToText($slug): string`\n\nConverts a URL-friendly slug back to readable text.\n\n```php\nuse Effectra\\ToString\\TextToString;\n\n$textToString = new TextToString();\n$result = $textToString-\u003eslugToText('hello-world');\necho $result; // Output: Hello World\n```\n\n#### `generateRandomText($length): string`\n\nGenerates a random text of specified length.\n\n```php\nuse Effectra\\ToString\\TextToString;\n\n$textToString = new TextToString();\n$result = $textToString-\u003egenerateRandomText(8);\necho $result; // Output: C4rN1QX7\n```\n\n### ArrayToString\n\n#### `array(array $array): string`\n\nConverts an array to a string representation.\n\n```php\nuse Effectra\\ToString\\ArrayToString;\n\n$result = ArrayToString::array(['apple', 'banana', 'cherry']);\necho $result; // Output: ['apple', 'banana', 'cherry']\n```\n\n#### `arrayToText(array $data, string $separator = ','): string`\n\nConverts an array to a string by joining its elements with a separator.\n\n```php\nuse Effectra\\ToString\\ArrayToString;\n\n$result = ArrayToString::arrayToText(['apple', 'banana', 'cherry']);\necho $result; // Output: apple,banana,cherry\n```\n\n#### `arrayToSlug(array $data): string`\n\nConverts an array to a URL-friendly slug by joining its elements with a separator.\n```php\nuse Effectra\\ToString\\ArrayToString;\n\n$arrayToString = new ArrayToString();\n$result = $arrayToString-\u003earrayToSlug(['apple', 'banana', 'cherry']);\necho $result; // Output: apple-banana-cherry\n```\n\n#### `arrayToTextKeyValue($data): string`\n\nConverts an array or JSON string to a key-value pair string representation.\n\n```php\nuse Effectra\\ToString\\ArrayToString;\n\n$arrayToString = new ArrayToString();\n$result = $arrayToString-\u003earrayToTextKeyValue(['name' =\u003e 'John', 'age' =\u003e 25, 'city' =\u003e 'New York']);\necho $result;\n/*\nOutput:\nname: John,\nage: 25,\ncity: New York,\n*/\n```\n\n### DateToString\n\n#### `formatTime(int $time): string`\n\nFormats a time value in seconds into HH:MM:SS format.\n\n```php\nuse Effectra\\ToString\\DateToString;\n\n$dateToString = new DateToString();\n$result = $dateToString-\u003eformatTime(3600); // Assuming 3600 seconds is 1 hour\necho $result; // Output: 01:00:00\n```\n\n#### `formatDate(int $timestamp): string`\n\nFormats a timestamp into YYYY-MM-DD format.\n\n```php\nuse Effectra\\ToString\\DateToString;\n\n$dateToString = new DateToString();\n$result = $dateToString-\u003eformatDate(time()); // Current timestamp\necho $result; // Output: 2023-05-13\n```\n\n## License\n\nThis library is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.\n\n## Contributing\n\nContributions are welcome! If you have any improvements or bug fixes, please submit a pull request.\n\n## Credits\n\nThe `to-string` library is developed and maintained by [Effectra](https://effectra.co/).\n\n## Support\n\nFor any questions or issues, please [open an issue](https://github.com/effectra/to-string/issues) on GitHub.\n\n\nFeel free to modify the README file according to your specific library details, such as author information, additional sections, or formatting preferences.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fto-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feffectra%2Fto-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fto-string/lists"}