{"id":14984001,"url":"https://github.com/agence-adeliom/easy-common-bundle","last_synced_at":"2025-04-10T19:43:23.577Z","repository":{"id":56941853,"uuid":"399090212","full_name":"agence-adeliom/easy-common-bundle","owner":"agence-adeliom","description":"A Symfony bundle for EasyAdmin that provide basic entity traits and a enum helper","archived":false,"fork":false,"pushed_at":"2025-03-19T19:07:59.000Z","size":36,"stargazers_count":4,"open_issues_count":2,"forks_count":6,"subscribers_count":1,"default_branch":"2.x","last_synced_at":"2025-03-24T17:21:25.375Z","etag":null,"topics":["easyadmin","symfony"],"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/agence-adeliom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-08-23T12:09:23.000Z","updated_at":"2025-03-19T19:04:36.000Z","dependencies_parsed_at":"2023-12-08T15:00:16.178Z","dependency_job_id":"cd66d12e-6760-4738-ab01-c0899b7d849d","html_url":"https://github.com/agence-adeliom/easy-common-bundle","commit_stats":{"total_commits":14,"total_committers":4,"mean_commits":3.5,"dds":0.5,"last_synced_commit":"90e195b63d93681e318fc4c0e63349730f1cce8f"},"previous_names":[],"tags_count":114,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agence-adeliom%2Feasy-common-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agence-adeliom%2Feasy-common-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agence-adeliom%2Feasy-common-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agence-adeliom%2Feasy-common-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agence-adeliom","download_url":"https://codeload.github.com/agence-adeliom/easy-common-bundle/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281424,"owners_count":21077423,"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":["easyadmin","symfony"],"created_at":"2024-09-24T14:08:18.118Z","updated_at":"2025-04-10T19:43:23.562Z","avatar_url":"https://github.com/agence-adeliom.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n![Adeliom](https://adeliom.com/public/uploads/2017/09/Adeliom_logo.png)\n[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=agence-adeliom_easy-common-bundle)](https://sonarcloud.io/dashboard?id=agence-adeliom_easy-common-bundle)\n\n# Easy Common Bundle\n\nProvide base utilities for Easyadmin.\n\n\n## Features\n\n- A Enum polyfill for PHP 8 (\u003c 8.1.0)\n- Some Traits for entities\n\n## Versions\n\n| Repository Branch | Version | Symfony Compatibility | PHP Compatibility | Status                     |\n|-------------------|---------|-----------------------|-------------------|----------------------------|\n| `3.x`             | `3.x`   | `6.4`, and `7.x`      | `8.2` or higher    | New features and bug fixes |\n| `2.x`             | `2.x`   | `5.4`, and `6.x`      | `8.0.2` or higher | Bug fixes                              |\n| `1.x`             | `1.x`   | `4.4`, and `5.x`      | `7.2.5` or higher | No longer maintained       |\n\n## Installation\n\nInstall with composer\n\n```bash\ncomposer require agence-adeliom/easy-common-bundle\n```\n\n### Traits\n\n* [ID](src/Traits/EntityIdTrait.php)\n* [Name and Slug](src/Traits/EntityNameSlugTrait.php)\n* [Name](src/Traits/EntityNameTrait.php)\n* [Publishable](src/Traits/EntityPublishableTrait.php)\n* [Status](src/Traits/EntityStatusTrait.php)\n* [Three State Status](src/Traits/EntityThreeStateStatusTrait.php)\n* [Timestampable](src/Traits/EntityTimestampableTrait.php)\n* [Soft Deletable](src/Traits/EntitySoftDeletableTrait.php)\n\n### Enum helper\n\n#### Declaration\n\n```php\nuse Adeliom\\EasyCommonBundle\\Helper\\Enum;\n\n/**\n * Action enum\n */\nfinal class Action extends Enum\n{\n    private const VIEW = 'view';\n    private const EDIT = 'edit';\n}\n```\n\n#### Usage\n\n```php\n$action = Action::VIEW();\n\n// or with a dynamic key:\n$action = Action::$key();\n// or with a dynamic value:\n$action = Action::from($value);\n// or\n$action = new Action($value);\n```\n\nAs you can see, static methods are automatically implemented to provide quick access to an enum value.\n\nOne advantage over using class constants is to be able to use an enum as a parameter type:\n\n```php\nfunction setAction(Action $action) {\n    // ...\n}\n```\n\n#### Documentation\n\n- `__construct()` The constructor checks that the value exist in the enum\n- `__toString()` You can `echo $myValue`, it will display the enum value (value of the constant)\n- `getValue()` Returns the current value of the enum\n- `getKey()` Returns the key of the current value on Enum\n- `equals()` Tests whether enum instances are equal (returns `true` if enum values are equal, `false` otherwise)\n\nStatic methods:\n\n- `from()` Creates an Enum instance, checking that the value exist in the enum\n- `toArray()` method Returns all possible values as an array (constant name in key, constant value in value)\n- `keys()` Returns the names (keys) of all constants in the Enum class\n- `values()` Returns instances of the Enum class of all Enum constants (constant name in key, Enum instance in value)\n- `isValid()` Check if tested value is valid on enum set\n- `isValidKey()` Check if tested key is valid on enum set\n- `assertValidValue()` Assert the value is valid on enum set, throwing exception otherwise\n- `search()` Return key for searched value\n\n##### Static methods\n\n```php\nfinal class Action extends Enum\n{\n    private const VIEW = 'view';\n    private const EDIT = 'edit';\n}\n\n// Static method:\n$action = Action::VIEW();\n$action = Action::EDIT();\n```\n\nStatic method helpers are implemented using [`__callStatic()`](http://www.php.net/manual/en/language.oop5.overloading.php#object.callstatic).\n\nIf you care about IDE autocompletion, you can either implement the static methods yourself:\n\n```php\nfinal class Action extends Enum\n{\n    private const VIEW = 'view';\n\n    /**\n     * @return Action\n     */\n    public static function VIEW() {\n        return new Action(self::VIEW);\n    }\n}\n```\n\nor you can use phpdoc (this is supported in PhpStorm for example):\n\n```php\n/**\n * @method static Action VIEW()\n * @method static Action EDIT()\n */\nfinal class Action extends Enum\n{\n    private const VIEW = 'view';\n    private const EDIT = 'edit';\n}\n```\n\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n\n\n## Authors\n\n- [@arnaud-ritti](https://github.com/arnaud-ritti)\n\n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagence-adeliom%2Feasy-common-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagence-adeliom%2Feasy-common-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagence-adeliom%2Feasy-common-bundle/lists"}