{"id":15578341,"url":"https://github.com/bayfrontmedia/php-string-helpers","last_synced_at":"2026-01-16T11:58:00.640Z","repository":{"id":62492271,"uuid":"282995182","full_name":"bayfrontmedia/php-string-helpers","owner":"bayfrontmedia","description":"PHP helper class to provide useful string functions.","archived":false,"fork":false,"pushed_at":"2026-01-14T15:33:53.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-14T19:13:45.067Z","etag":null,"topics":["function","helper","helpers","php","string"],"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/bayfrontmedia.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","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":"2020-07-27T19:25:46.000Z","updated_at":"2026-01-14T15:33:32.000Z","dependencies_parsed_at":"2024-12-06T13:39:22.669Z","dependency_job_id":"bdcd8a5b-e6a4-4745-902e-3edc8604b690","html_url":"https://github.com/bayfrontmedia/php-string-helpers","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"c2e9fde8d3f8ace03c4b31cea3eb79039c0dd6fd"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/bayfrontmedia/php-string-helpers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bayfrontmedia%2Fphp-string-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bayfrontmedia%2Fphp-string-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bayfrontmedia%2Fphp-string-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bayfrontmedia%2Fphp-string-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bayfrontmedia","download_url":"https://codeload.github.com/bayfrontmedia/php-string-helpers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bayfrontmedia%2Fphp-string-helpers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"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":["function","helper","helpers","php","string"],"created_at":"2024-10-02T19:09:16.118Z","updated_at":"2026-01-16T11:58:00.631Z","avatar_url":"https://github.com/bayfrontmedia.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## PHP string helpers\n\nPHP helper class to provide useful string functions.\n\n- [License](#license)\n- [Author](#author)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n\n## License\n\nThis project is open source and available under the [MIT License](LICENSE).\n\n## Author\n\n\u003cimg src=\"https://cdn1.onbayfront.com/bfm/brand/bfm-logo.svg\" alt=\"Bayfront Media\" width=\"250\" /\u003e\n\n- [Bayfront Media homepage](https://www.bayfrontmedia.com?utm_source=github\u0026amp;utm_medium=direct)\n- [Bayfront Media GitHub](https://github.com/bayfrontmedia)\n\n## Requirements\n\n* PHP `^8.0` (Tested up to `8.4`)\n\n## Installation\n\n```\ncomposer require bayfrontmedia/php-string-helpers\n```\n\n## Usage\n\n- [startWith](#startwith)\n- [endWith](#endwith)\n- [lowercase](#lowercase)\n- [uppercase](#uppercase)\n- [titleCase](#titlecase)\n- [camelCase](#camelcase)\n- [kebabCase](#kebabcase)\n- [snakeCase](#snakecase)\n- [random](#random)\n- [uid](#uid)\n- [uuid4](#uuid4)\n- [uuid7](#uuid7)\n- [isValidUuid](#isvaliduuid)\n- [binToUuid](#bintouuid)\n- [uuidToBin](#uuidtobin)\n- [hasComplexity](#hascomplexity)\n\nDepreciated:\n\n- [has](#has)\n- [hasSpace](#hasspace)\n- [startsWith](#startswith)\n- [endsWith](#endswith)\n- [uuid](#uuid)\n\n\u003chr /\u003e\n\n### startWith\n\n**Description:**\n\nReturns string, ensuring that it starts with a given string.\n\n**Parameters:**\n\n- `$string` (string)\n- `$start_with` (string)\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$string = 'This is a string.';\n\necho Str::startWith($string, 'Hello! ');\n```\n\n\u003chr /\u003e\n\n### endWith\n\n**Description:**\n\nReturns string, ensuring that it ends with a given string.\n\n**Parameters:**\n\n- `$string` (string)\n- `$end_with` (string)\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$string = 'This is a string.';\n\necho Str::endWith($string, ' Goodbye!');\n```\n\n\u003chr /\u003e\n\n### lowercase\n\n**Description:**\n\nConverts string to lowercase using a specified character encoding.\n\nSee: [https://www.php.net/manual/en/mbstring.supported-encodings.php](https://www.php.net/manual/en/mbstring.supported-encodings.php)\n\n**Parameters:**\n\n- `$string` (string)\n- `$encoding = 'UTF-8'` (string)\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$string = 'This is a string.';\n\necho Str::lowercase($string);\n```\n\n\u003chr /\u003e\n\n### uppercase\n\n**Description:**\n\nConverts string to uppercase using a specified character encoding.\n\nSee: [https://www.php.net/manual/en/mbstring.supported-encodings.php](https://www.php.net/manual/en/mbstring.supported-encodings.php)\n\n**Parameters:**\n\n- `$string` (string)\n- `$encoding = 'UTF-8'` (string)\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$string = 'This is a string.';\n\necho Str::uppercase($string);\n```\n\n\u003chr /\u003e\n\n### titleCase\n\n**Description:**\n\nConverts string to title case using a specified character encoding.\n\nSee: [https://www.php.net/manual/en/mbstring.supported-encodings.php](https://www.php.net/manual/en/mbstring.supported-encodings.php)\n\n**Parameters:**\n\n- `$string` (string)\n- `$encoding = 'UTF-8'` (string)\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$string = 'This is a string.';\n\necho Str::titleCase($string);\n```\n\n\u003chr /\u003e\n\n### camelCase\n\n**Description:**\n\nConverts string to camel case, removing any non-alpha and non-numeric characters.\n\n**Parameters:**\n\n- `$string` (string)\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$string = 'This is a string.';\n\necho Str::camelCase($string);\n```\n\n\u003chr /\u003e\n\n### kebabCase\n\n**Description:**\n\nConverts string to kebab case (URL-friendly slug), replacing any non-alpha and non-numeric characters with a hyphen.\n\n**Parameters:**\n\n- `$string` (string)\n- `$lowercase = false` (bool): Convert string to lowercase\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$string = 'This is a string.';\n\necho Str::kebabCase($string);\n```\n\n\u003chr /\u003e\n\n### snakeCase\n\n**Description:**\n\nConverts string to snake case, replacing any non-alpha and non-numeric characters with an underscore.\n\n**Parameters:**\n\n- `$string` (string)\n- `$lowercase = false` (bool): Convert string to lowercase\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$string = 'This is a string.';\n\necho Str::snakeCase($string);\n```\n\n\u003chr /\u003e\n\n### random\n\n**Description:**\n\nReturn a random string of specified length and type.\n\n**Note: Returned string is not cryptographically secure.**\n\n**Parameters:**\n\n- `$length = 8` (int)\n- `$type = self::RANDOM_TYPE_ALL` (string): Any `RANDOM_TYPE_*` constant)\n\nValid `$type` constants include:\n\n- `RANDOM_TYPE_NONZERO`\n- `RANDOM_TYPE_NUMERIC`\n- `RANDOM_TYPE_ALPHA`: Alphabetic, upper and lowercase\n- `RANDOM_TYPE_ALPHA_LOWER`\n- `RANDOM_TYPE_ALPHA_UPPER`\n- `RANDOM_TYPE_ALPHANUMERIC`: Alphanumeric, upper and lowercase\n- `RANDOM_TYPE_ALPHANUMERIC_LOWER`\n- `RANDOM_TYPE_ALPHANUMERIC_UPPER`\n- `RANDOM_TYPE_ALL`: Alphanumeric and special characters\n\nBackticks and quotation marks are excluded from special characters for safely inserting into a database.\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\necho Str::random(16, Str::RANDOM_TYPE_ALPHANUMERIC);\n```\n\n\u003chr /\u003e\n\n### uid\n\n**Description:**\n\nReturn a cryptographically secure unique identifier (UID) comprised of lowercase letters and numbers.\n\n**Parameters:**\n\n- `$length = 8` (int)\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\necho Str::uid(16);\n```\n\n### uuid4\n\n**Description:**\n\nReturn a UUID v4 string.\n\n**Parameters:**\n\n- (None)\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\necho Str::uuid4();\n```\n\n\u003chr /\u003e\n\n### uuid7\n\n**Description:**\n\nReturn a lexicographically sortable UUID v7 string.\n\n**Parameters:**\n\n- (None)\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\necho Str::uuid7();\n```\n\n\u003chr /\u003e\n\n### isValidUuid\n\n**Description:**\n\nIs string a valid UUID?\n\n**Parameters:**\n\n- `$uuid` (string)\n\n**Returns:**\n\n- (boolean)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\nif (!Str::isValidUuid('9b77a49f-5d5a-4699-a8e0-21d010fdd9bc')) {\n    // Do something\n}\n```\n\n\u003chr /\u003e\n\n### binToUuid\n\n**Description:**\n\nConvert 16 byte binary string to UUID.\n\n**Parameters:**\n\n- `$binary` (string)\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$uuid = Str::binToUuid($binary);\n```\n\n\u003chr /\u003e\n\n### uuidToBin\n\n**Description:**\n\nConvert UUID to 16 byte binary string.\n\n**Parameters:**\n\n- `$uuid` (string)\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$bin = Str::uuidToBin('9b77a49f-5d5a-4699-a8e0-21d010fdd9bc');\n```\n\n\u003chr /\u003e\n\n### hasComplexity\n\n**Description:**\n\nVerify input string has a specified complexity.\n\n**Parameters:**\n\n- `$string` (string)\n- `$min_length` (int)\n- `$max_length` (int): `0` for no max\n- `$lowercase` (int): Minimum number of lowercase characters\n- `$uppercase` (int): Minimum number of uppercase characters\n- `$digits` (int): Minimum number of digits\n- `$special_chars` (int): Minimum number of non-alphabetic and non-numeric characters\n\n**Returns:**\n\n- (bool)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\nif (!Str::hasComplexity('abc123', 8, 32, 1, 1, 1, 1)) {\n    // Do something\n}\n```\n\n\u003chr /\u003e\n\n### ~~has~~\n\n**Description:**\n\nChecks if string contains a case-sensitive needle.\n\nThis method has been depreciated in favor of PHP native function `str_contains`.\n\n**Parameters:**\n\n- `$string` (string)\n- `$needle` (string)\n\n**Returns:**\n\n- (bool)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$string = 'This is a string.';\n\nif (Str::has($string, 'this')) {\n\n    // Do something\n\n}\n```\n\n\u003chr /\u003e\n\n### ~~hasSpace~~\n\n**Description:**\n\nChecks if string contains any whitespace.\n\nThis method has been depreciated in favor of PHP native function `str_contains`.\n\n**Parameters:**\n\n- `$string` (string)\n\n**Returns:**\n\n- (bool)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$string = 'This is a string.';\n\nif (Str::hasSpace($string)) {\n\n    // Do something\n\n}\n```\n\n\u003chr /\u003e\n\n### ~~startsWith~~\n\n**Description:**\n\nChecks if a string starts with a given case-sensitive string.\n\nThis method has been depreciated in favor of PHP native function `str_starts_with`.\n\n**Parameters:**\n\n- `$string` (string)\n- `$starts_with` (string)\n\n**Returns:**\n\n- (bool)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$string = 'This is a string.';\n\nif (Str::startsWith($string, 'this')) {\n\n    // Do something\n\n}\n```\n\n\u003chr /\u003e\n\n### ~~endsWith~~\n\n**Description:**\n\nChecks if a string ends with a given case-sensitive string.\n\nThis method has been depreciated in favor of PHP native function `str_ends_with`.\n\n**Parameters:**\n\n- `$string` (string)\n- `$ends_with` (string)\n\n**Returns:**\n\n- (bool)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\n$string = 'This is a string.';\n\nif (Str::endsWith($string, 'string.')) {\n\n    // Do something\n\n}\n```\n\n\u003chr /\u003e\n\n### ~~uuid~~\n\n**Description:**\n\nReturn a UUID v4 string.\n\nThis method has been depreciated in favor of [Str::uuid4](#uuid4) and [Str::uuid7](#uuid7).\n\n**Parameters:**\n\n- (None)\n\n**Returns:**\n\n- (string)\n\n**Example:**\n\n```php\nuse Bayfront\\StringHelpers\\Str;\n\necho Str::uuid();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbayfrontmedia%2Fphp-string-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbayfrontmedia%2Fphp-string-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbayfrontmedia%2Fphp-string-helpers/lists"}