{"id":18840144,"url":"https://github.com/seothemes/php-case-converter","last_synced_at":"2025-06-17T20:40:00.487Z","repository":{"id":87409738,"uuid":"252676178","full_name":"seothemes/php-case-converter","owner":"seothemes","description":"PHP function to convert a string to another naming convention","archived":false,"fork":false,"pushed_at":"2020-04-03T08:50:14.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-29T20:47:08.346Z","etag":null,"topics":["camelcase","case-converter","php","snakecase"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seothemes.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":"2020-04-03T08:35:06.000Z","updated_at":"2022-03-12T03:28:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"bc5dd33e-7120-45d5-ac88-d1749c6c006a","html_url":"https://github.com/seothemes/php-case-converter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/seothemes/php-case-converter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seothemes%2Fphp-case-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seothemes%2Fphp-case-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seothemes%2Fphp-case-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seothemes%2Fphp-case-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seothemes","download_url":"https://codeload.github.com/seothemes/php-case-converter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seothemes%2Fphp-case-converter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260439061,"owners_count":23009269,"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":["camelcase","case-converter","php","snakecase"],"created_at":"2024-11-08T02:45:11.629Z","updated_at":"2025-06-17T20:39:55.473Z","avatar_url":"https://github.com/seothemes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Case Converter\n\nSimple PHP function that takes a string and converts it to another naming convention.\n\n\n### The code\n\n\n```php\n/**\n * Converts a string to different naming conventions.\n *\n * @since  1.0.0\n *\n * @author Lee Anthony https://seothemes.com\n *\n * @param string $string String to convert.\n * @param string $case   Naming convention.\n *\n * @return string\n */\nfunction convert_case( $string, $case = 'snake' ) {\n\t$delimiters = 'sentence' === $case ? [ ' ', '-', '_' ] : [ ' ', '-', '_', '.' ];\n\t$lower      = trim( str_replace( $delimiters, $delimiters[0], strtolower( $string ) ), $delimiters[0] );\n\t$upper      = trim( ucwords( $lower ), $delimiters[0] );\n\t$pieces     = explode( $delimiters[0], $lower );\n\n\t$cases = [\n\t\t'camel'    =\u003e lcfirst( str_replace( ' ', '', $upper ) ),\n\t\t'pascal'   =\u003e str_replace( ' ', '', $upper ),\n\t\t'snake'    =\u003e strtolower( implode( '_', $pieces ) ),\n\t\t'ada'      =\u003e str_replace( ' ', '_', $upper ),\n\t\t'macro'    =\u003e strtoupper( implode( '_', $pieces ) ),\n\t\t'kebab'    =\u003e strtolower( implode( '-', $pieces ) ),\n\t\t'train'    =\u003e lcfirst( str_replace( ' ', '-', $upper ) ),\n\t\t'cobol'    =\u003e strtoupper( implode( '-', $pieces ) ),\n\t\t'lower'    =\u003e strtolower( $string ),\n\t\t'upper'    =\u003e strtoupper( $string ),\n\t\t'title'    =\u003e $upper,\n\t\t'sentence' =\u003e ucfirst( $lower ),\n\t\t'dot'      =\u003e strtolower( implode( '.', $pieces ) ),\n\t];\n\n\treturn $cases[ $case ];\n}\n```\n\n\n### How to use\n\n\nCopy and paste the helper function into your project, then use it:\n\n```php\necho convert_case( 'This is_an example-string.', 'camel' ); // Outputs: thisIsAnExampleString\n```\n\n\n### Available cases\n\n\n| Case     | Example |\n| -------- | ------- |\n| camel    | myNameIsBond |\n| pascal   | MyNameIsBond |\n| snake    | my_name_is_bond |\n| ada      | My_Name_Is_Bond |\n| macro    | MY_NAME_IS_BOND |\n| kebab    | my-name-is-bond |\n| train    | My-Name-Is-Bond |\n| cobol    | MY-NAME-IS-BOND |\n| lower    | my name is bond |\n| upper    | MY NAME IS BOND |\n| title    | My Name Is Bond |\n| sentence | My name is bond |\n| dot      | my.name.is.bond |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseothemes%2Fphp-case-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseothemes%2Fphp-case-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseothemes%2Fphp-case-converter/lists"}