{"id":30873747,"url":"https://github.com/jonesiscoding/code-objects","last_synced_at":"2025-09-07T23:50:13.419Z","repository":{"id":56966718,"uuid":"456693477","full_name":"jonesiscoding/code-objects","owner":"jonesiscoding","description":"PHP tools for the resolution of class names from strings and vice versa.","archived":false,"fork":false,"pushed_at":"2024-09-11T13:22:29.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-19T21:28:23.467Z","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":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonesiscoding.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":"2022-02-07T22:05:19.000Z","updated_at":"2024-09-11T13:23:23.000Z","dependencies_parsed_at":"2024-09-11T18:53:51.372Z","dependency_job_id":"3f7e25f0-508d-4c8a-89d3-fec91702db1b","html_url":"https://github.com/jonesiscoding/code-objects","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":0.09090909090909094,"last_synced_commit":"28a5cf3f2084c00e9074a6fb750697e1c8ea5852"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/jonesiscoding/code-objects","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonesiscoding%2Fcode-objects","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonesiscoding%2Fcode-objects/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonesiscoding%2Fcode-objects/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonesiscoding%2Fcode-objects/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonesiscoding","download_url":"https://codeload.github.com/jonesiscoding/code-objects/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonesiscoding%2Fcode-objects/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274113046,"owners_count":25224334,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-09-07T23:50:04.397Z","updated_at":"2025-09-07T23:50:13.416Z","avatar_url":"https://github.com/jonesiscoding.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Code Objects\nPHP Library which includes classes for the resolution of class names and callables, as well as the manipulation of\ncode construct strings such as class names, method names, CSS classes, HTML5 ids, table names, and more.\n\nUsing this library?  I'd love to hear about it! Star the repo, or mention [@jonesiscoding](https://twitter.com/jonesiscoding/)\nin a tweet!\n\n## Version Objects\n\nThere are two version objects designed for parsing and comparing Semantic Version numbers, `Version` and `VersionImmutable`.\n\n## Construct Objects\n\nThere are three main construct objects: `ConstructString`, `ClassString` and `MethodString`.  Both `ClassString` and\n`MethodString` are extensions of `ConstructString`.\n\nThe base `ConstructString` class to work with the name of any coding construct such as a table, class, method, key, etc.\n\nThe more specific `ClassString` and `MethodString` contain additional methods for dealing with situations specific to a\nmethod name or a class name such as extracting the class name, the namespace, the function name, etc.\n\n### Common Methods\n\n| Method     | Purpose                                                                                   |\n|------------|-------------------------------------------------------------------------------------------|\n| `css`      | Sanitizes a string for use as a CSS class, or HTML5 id.                                   |\n| `camelize` | Changes _class_name_ to _className_ (camelCase)                                           |\n| `classify` | Changes _class_name_ to _ClassName_ (PascalCase)                                          |\n| `slugify`  | Removes all special characters and replaced spacers with dashes or the provided separator | \n| `snakeize`  | Changes _ClassName_ to _class_name_ (snake_case)                                          |\n\n## Resolver Classes\n\nThe resolver classes are aimed at allowing for the resolution of PHP classes and callables.  At most times during\ndevelopment, the use of autoloaders and PSR-0 or PSR-4 structure would prevent the need for the resolution of classes\nand callables. \n\nThese classes can be useful, however, in situations where callables are configured outside your code base, such as\nin a YAML or XML configuration file or in a database. Often in these situations, callables and classes are referred to\nwith a key or id, rather than the fully qualified class name\n\nAnother situation in which these classes can be useful is when you have multiple classes that could be used, and these\nclasses exist in multiple name spaces. For example, when some classes that implement a specific interface are part of\nyour code base, but others may be part of a vendor library.\n\nEach class contains one main method: `resolve`, which will resolve the given string, array, or object.\n\n### Class Resolver\n\nAt instantiation, this class is provided a namespace or \"sibling\" class (from which to derive a namespace).  An array\nof namespaces or sibling classes may also be provided.\n\nWhen the `resolve` method is called, it resolves the provided string into a fully qualified class name by matching to\nexisting classes within the namespaces provided to the resolver at instantiation.\n\n### Implementation Resolver\n\nThis class functions the same as the `ClassResolver`, but only resolves classes that implement the interface given at \nthe time of instantiation.\n\n### Callback Resolver\n\nThe `CallbackResolver` class is also provided a namespace or \"sibling\" class at instantiation, and will also take an\narray of namespaces or sibling classes.\n\nWhen the `resolve` method is called, it resolves the provided string, array, or object into a `\\Closure` by first\nresolving any class as needed, instantiating and needed object (if possible), verifying that the requested method is\ncallable, then converting the callable into a `\\Closure`.\n\nThe item to resolve may be in any of these formats:  \n\n* `ClassName::methodString` (works with non-static methods too)\n* `\\Fully\\Qualified\\ClassName::methodString` (works with non-static methods too)\n* `['ClassName', 'methodString']`\n* `['\\Fully\\Qualified\\ClassName', 'methodString']`\n* `'InvokableClassName'`\n* `'\\Fully\\Qualified\\InvokableClassName`\n\nThese may also be provided. Though they would need no resolution, they would be validated to be callable and turned\ninto a `\\Closure`.\n\n* `InvokableObject`\n* [Object, 'methodString']\n\n### ContainerAwareCallbackResolver\n\nThe `ContainerAwareCallbackResolver` must be provided a *PSR-11 Container Interface* at instantiation, and may also be\nprovided optional namespaces or \"sibling\" classes at instantiation.  The `ContainerInterface` object is used as a\ndependency injection service locator, for example, the container used in the Symfony framework.\n\nWhen the `resolve` method is called, this resolver type will attempt to match the *class* portion of any item to an \n*id* of a service in the `ContainerInterface`, then proceed with resolving the rest of the callback.\n\n### Closure\n\nThe `Closure` class is a super-charged drop-in replacement for PHP 7.1's `\\Closure::fromCallable`, and works using a\nmethod of the same name.  This class is not intended for separate use, but instead does the \"heavy lifting\" for the \n`CallbackResolver`, taking either an array or a string that should be callable, instantiates any class into an object\n(if necessary and possible), then creates a closure from the resulting callable.\n\nIn PHP 7.1+, the original `\\Closure::fromCallable` is used for the final step.  In previous versions, the resulting\n`\\Closure` is created \"the old fashioned way\"\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonesiscoding%2Fcode-objects","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonesiscoding%2Fcode-objects","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonesiscoding%2Fcode-objects/lists"}