{"id":22496970,"url":"https://github.com/morebec/orkestra-enum","last_synced_at":"2026-05-13T12:39:55.605Z","repository":{"id":49499872,"uuid":"359991309","full_name":"Morebec/orkestra-enum","owner":"Morebec","description":"[READ ONLY] Orkestra component providing enums","archived":false,"fork":false,"pushed_at":"2023-03-31T18:46:11.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"2.x","last_synced_at":"2025-07-08T14:54:38.166Z","etag":null,"topics":["enum","orkestra","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Morebec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2021-04-21T00:53:44.000Z","updated_at":"2021-07-05T16:42:46.000Z","dependencies_parsed_at":"2024-12-06T20:15:16.807Z","dependency_job_id":"d0897c4a-35ff-4605-ad83-d3c85a419f09","html_url":"https://github.com/Morebec/orkestra-enum","commit_stats":{"total_commits":5,"total_committers":2,"mean_commits":2.5,"dds":"0.19999999999999996","last_synced_commit":"8c13263540c3945dc74753c24253bd1f2a0fd4e3"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/Morebec/orkestra-enum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2Forkestra-enum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2Forkestra-enum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2Forkestra-enum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2Forkestra-enum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Morebec","download_url":"https://codeload.github.com/Morebec/orkestra-enum/tar.gz/refs/heads/2.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2Forkestra-enum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280783851,"owners_count":26390277,"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-10-24T02:00:06.418Z","response_time":73,"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":["enum","orkestra","php"],"created_at":"2024-12-06T20:15:04.595Z","updated_at":"2025-10-24T10:52:59.082Z","avatar_url":"https://github.com/Morebec.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Enum\n\nThis Orkestra component provides typed enumerations to PHP.\n\n## Installation\n```shell\ncomposer require morebec/orkestra-orkestra-enum\n```\n\n## Usage\n\n### Creating an Enum \nTo create a new Enum, one needs to extend the `Enum` class. \nAs an example, lets pretend we want to create a `CardinalPoint` Class. \nSince there are strictly 4 cardinal points, this is a good candidate for an Enum:\n```php\nclass CardinalPoint extends Enum\n{\n    const NORTH = 'NORTH';    \n    const EAST = 'EAST';    \n    const WEST = 'WEST';  \n    const SOUTH = 'SOUTH';\n}\n```\n\nSimply doing this, will allow us to use our class in the following way:\n```php\n// Instantiate a new CardinalPoint instance\n$direction = new CardinalPoint(CardinalPoint::NORTH);\n\n// Since Enums have builtin validation,\n// the following line would throw an InvalidArgumentException:\n$direction = new CardinalPoint('North');\n\n// However the following would work:\n$direction = new CardinalPoint('NORTH');\n\n// Using in functions or class methods \npublic function changeDirection(CardinalPoint $direction)\n{\n    // Testing equlity with string\n    if(!$direction-\u003eisEqualTo(new CardinalPoint(CardinalPoint::EAST))) {\n        echo 'Not going East!';\n    }\n\n    // Since the constants are strings, it is also possible to compare\n    // using loose comparison\n    if($direction == CardinalPoint::NORTH) {\n        echo 'Definitely going North!';\n    }    \n}\n```\n\n\u003e For easier IDE integration we can even go further adding `@method` annotations to the Enum class:\n\u003e ```php\n\u003e /**\n \u003e * @method static self NORTH() \n \u003e * @method static self EAST() \n \u003e * @method static self WEST() \n \u003e * @method static self SOUTH() \n \u003e */\n\u003e class CardinalPoint extends Enum\n\u003e {\n\u003e    const NORTH = 'NORTH';    \n\u003e    const EAST = 'EAST';    \n\u003e    const WEST = 'WEST';  \n\u003e    const SOUTH = 'SOUTH';\n\u003e }\n\u003e ```\n\u003e This will allow us to do the following in code:\n\u003e ```php\n\u003e $direction = CardinalPoint::NORTH();\n\u003e ```\n\n### Getting all possible values\nIn order to get all the possible values as an array you can use the static method `getValues`:\n```php\nCardinalPoint::getValues(); \n// Returns an array as: \n// [ 'NORTH', 'EAST', 'WEST', 'SOUTH' ]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorebec%2Forkestra-enum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorebec%2Forkestra-enum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorebec%2Forkestra-enum/lists"}