{"id":24540672,"url":"https://github.com/mistralys/application-utils-collections","last_synced_at":"2025-03-16T05:43:28.780Z","repository":{"id":200375429,"uuid":"704442179","full_name":"Mistralys/application-utils-collections","owner":"Mistralys","description":"Interfaces, traits and classes for handling static item collections like item statuses or criticality levels.","archived":false,"fork":false,"pushed_at":"2024-07-25T15:01:22.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-24T00:46:39.405Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mistralys.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-13T09:10:18.000Z","updated_at":"2024-07-25T14:59:54.000Z","dependencies_parsed_at":"2024-07-25T17:11:32.372Z","dependency_job_id":null,"html_url":"https://github.com/Mistralys/application-utils-collections","commit_stats":null,"previous_names":["mistralys/application-utils-collections"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mistralys%2Fapplication-utils-collections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mistralys%2Fapplication-utils-collections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mistralys%2Fapplication-utils-collections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mistralys%2Fapplication-utils-collections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mistralys","download_url":"https://codeload.github.com/Mistralys/application-utils-collections/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830914,"owners_count":20354850,"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":[],"created_at":"2025-01-22T18:14:38.723Z","updated_at":"2025-03-16T05:43:28.757Z","avatar_url":"https://github.com/Mistralys.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AppUtils - Collections\n\nInterfaces, traits and classes for handling static item collections,\nsimilar to Enums and with useful getter methods. \n\nIn essence, it allows creating collections like this with a \nminimum of code:\n\n```php\n$basil = Herbs::getInstance()-\u003egetByID(Herbs::BASIL);\n\necho $basil-\u003egetID(); // basil\necho $basil-\u003egetName(); // Basil\n```\n\n```php\nforeach(Herbs::getInstance()-\u003egetAll() as $herb) {\n    echo $herb-\u003egetName();\n}\n```\n\n\u003e This is part of the [Application Utils][] ecology.\n\n## The Principle\n\nThe basic principle is to have a collection class for a data type,\nwhich knows all the possible values for that type, and a record class\nthat represents a single value of that type.\n\nThe collections and records are distinguished by the return type of\ntheir `getID()` method. \n\n\u003e Currently, only string and integer types are supported.\n\n## Implementation\n\nThere are two ways to implement collections: \n\n1. By extending the abstract base classes (e.g. `BaseStringPrimaryCollection`)\n2. By implementing the interface and trait (e.g. `StringPrimaryCollectionTrait`)\n\n\u003e The second way is useful when working with classes that already \n\u003e extend another class.\n\nThe records have no abstract base class, only an interface that\ncontains the `getID()` method with the relevant return type.\n\n## Usage\n\nThere are example implementations of the string and integer collections\nin the unit test classes:\n\n- [Integer collection](tests/AppUtilsTestClasses/IntegerPrimaryCollectionImpl.php)\n- [Integer record](tests/AppUtilsTestClasses/IntegerPrimaryRecordImpl.php)\n- [String collection](tests/AppUtilsTestClasses/IntegerPrimaryCollectionImpl.php)\n- [String record](tests/AppUtilsTestClasses/IntegerPrimaryRecordImpl.php)\n- [String collection, with class folder loading](tests/AppUtilsTestClasses/StringPrimaryFolderCollectionImpl.php)\n\n\n[Application Utils]: https://github.com/Mistralys/application-utils\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmistralys%2Fapplication-utils-collections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmistralys%2Fapplication-utils-collections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmistralys%2Fapplication-utils-collections/lists"}