{"id":16721180,"url":"https://github.com/khalyomede/expose","last_synced_at":"2025-10-04T10:35:40.211Z","repository":{"id":57006140,"uuid":"123177503","full_name":"khalyomede/expose","owner":"khalyomede","description":"Expose your classes through functions to speed up your development","archived":false,"fork":false,"pushed_at":"2018-03-31T19:25:34.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T03:47:37.535Z","etag":null,"topics":["class","development","expose","function","php","productivity","speedup"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/khalyomede/expose","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/khalyomede.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-27T19:28:55.000Z","updated_at":"2018-03-31T19:25:36.000Z","dependencies_parsed_at":"2022-08-21T14:30:47.840Z","dependency_job_id":null,"html_url":"https://github.com/khalyomede/expose","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khalyomede%2Fexpose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khalyomede%2Fexpose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khalyomede%2Fexpose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khalyomede%2Fexpose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/khalyomede","download_url":"https://codeload.github.com/khalyomede/expose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243727299,"owners_count":20337968,"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":["class","development","expose","function","php","productivity","speedup"],"created_at":"2024-10-12T22:29:12.876Z","updated_at":"2025-10-04T10:35:40.118Z","avatar_url":"https://github.com/khalyomede.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Warning\n\nThis package is now abandoned because of security issue regarding a core function of php (more information by following [this link](http://php.net/manual/en/function.create-function.php)).\n\n# Expose\n\n![PHP from Packagist](https://img.shields.io/packagist/php-v/khalyomede/expose.svg)\n![Packagist](https://img.shields.io/packagist/v/khalyomede/expose.svg)\n![Packagist](https://img.shields.io/packagist/l/khalyomede/expose.svg)\n\nExpose your classes through functions to speed up your development.\n\nFrom \n\n```php\n$collection = new Collection(['Dreamer', 'Thunderbird', 'Eclipse']);\n\n$items = $collection-\u003eall();\n```\n\nTo\n\n```php\nExpose::make('Collection', 'collect');\n\n$items = collect(['Dreamer', 'Thunderbird', 'Eclipse'])-\u003eall();\n```\n\n## Summary\n\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n- [Examples of uses](#examples-of-uses)\n- [Methods definitions](#methods-definitions)\n- [MIT Licence](#mit-licence)\n\n## Prerequisites\n\n- PHP version \u003e= 7.0.0\n\n## Installation\n\nIn your project folder:\n\n```bash\ncomposer require khalyomede/expose:1.*\n```\n\n## Examples of uses\n\nAll the examples are available inside `/example` folder.\n\nAll the examples bellow assume the following classes exists:\n\n```php\nclass Collection {\n  protected $items;\n\n  public function __construct($items) {\n    $this-\u003eitems = $items;\n  }\n\n  public function all() {\n    return $this-\u003eitems;\n  }\n}\n\nclass Log {\n  protected $message;\n\n  public function __construct($message) {\n    $this-\u003emessage = $message;\n  }\n\n  public function error() {\n    echo sprintf('Error: %s', $this-\u003emessage) . PHP_EOL;\n  }\n}\n```\n\n- [Example 1: exposing a simple class](#example-1-exposing-a-simple-class)\n- [Example 2: exposing multiples classes at once](#example-2-exposing-multiple-classes-at-once)\n\n### Example 1: exposing a simple class\n\n```php\nuse Khalyomede\\Expose;\n\nExpose::make('Collection', 'collection');\n\n// or \n\nExpose::make(Collection::class, 'collection');\n\n$items = collection(['Thunderbird', 'Polaris', 'Eclipse'])-\u003eall();\n\nprint_($items);\n```\n\nWill display:\n\n```\nArray \n(\n  [0] =\u003e Thunderbird\n  [1] =\u003e Polaris\n  [2] =\u003e Eclipse\n)\n```\n\n### Example 2: exposing multiple classes at once\n\n```php\nuse Khalyomede\\Expose;\n\nExpose::make([\n  [Collection::class, 'collector'],\n  [Log::class, 'logging'] // beware of existing functions!\n]);\n\n$items = collector(['Thunderbird', 'Polaris', 'Eclipse'])-\u003eall();\n\nprint_r($items);\n\nlogging(\"duplicate entry 'Dreamer' on line 9\")-\u003eerror();\n```\n\nWill display:\n\n```\nArray\n(\n  [0] =\u003e Thunderbird\n  [1] =\u003e Polaris\n  [2] =\u003e Eclipse\n)\nduplicate entry 'Dreamer' on line 9\n```\n\n## Methods definition\n\n- [make()](#make)\n\n### make()\n\nExpose the class using its alias a shortcut, and create the related function.\n\n```php\npublic static function make(string $class_name, string $function_name): void\npublic static function make(array $exposures): void\n```\n\n**Exceptions**\n\n`InvalidArgumentException`:\n\n- If the first parameter is not a string when using 2 parameters\n- If the second parameter is not a string when using 2 parameters\n- If the function name already exists\n- If the parameter is not an array when using a single parameter\n- If the parameter is not an array of array when using a single parameter\n- If the paramter is not an array of array containing string when using a single parameter\n- If the parameter contains an empty row on its array of array when using a single parameter\n\n**Note**\n\nThis function can exposes static classes as well.\n\n## MIT Licence\n\nExpose\n\nCopyright © 2018 Khalyomede\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the oftware, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n \nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN CTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhalyomede%2Fexpose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhalyomede%2Fexpose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhalyomede%2Fexpose/lists"}