{"id":18552033,"url":"https://github.com/baraja-core/variable-generator","last_synced_at":"2025-05-15T11:11:06.719Z","repository":{"id":48336225,"uuid":"329096326","full_name":"baraja-core/variable-generator","owner":"baraja-core","description":"Generate new variable symbol by last variable and selected strategy.","archived":false,"fork":false,"pushed_at":"2024-01-23T04:08:50.000Z","size":54,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-02T21:19:41.216Z","etag":null,"topics":["generator","invoice","number","order","shop","variable"],"latest_commit_sha":null,"homepage":"https://baraja.cz","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/baraja-core.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},"funding":{"github":"janbarasek","custom":["https://brj.app","https://baraja.cz","https://php.baraja.cz"]}},"created_at":"2021-01-12T19:53:11.000Z","updated_at":"2022-01-10T14:40:50.000Z","dependencies_parsed_at":"2024-11-06T21:11:47.191Z","dependency_job_id":"905a7d75-6a03-4ab7-b01e-af7d3b7a6944","html_url":"https://github.com/baraja-core/variable-generator","commit_stats":{"total_commits":37,"total_committers":2,"mean_commits":18.5,"dds":0.05405405405405406,"last_synced_commit":"a952756c26b9493e66484f3bec98168489f22e33"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baraja-core%2Fvariable-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baraja-core%2Fvariable-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baraja-core%2Fvariable-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baraja-core%2Fvariable-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baraja-core","download_url":"https://codeload.github.com/baraja-core/variable-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328389,"owners_count":22052633,"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":["generator","invoice","number","order","shop","variable"],"created_at":"2024-11-06T21:11:43.250Z","updated_at":"2025-05-15T11:11:01.713Z","avatar_url":"https://github.com/baraja-core.png","language":"PHP","readme":"Variable generator\n======================\n\n![Integrity check](https://github.com/baraja-core/variable-generator/workflows/Integrity%20check/badge.svg)\n\nGenerate new variable symbol by last variable and selected strategy.\n\nIdea\n----\n\nA series of smart tools for generating variable symbols and order numbers in your e-shop.\n\nGenerating order numbers or other number series hides a number of complex problems. For example, adhering to the specified format according to the specification, handling transaction entries (to avoid duplication) and handling the case when the generated value overflows.\n\nThis package contains a set of algorithms and ready-made strategies to elegantly solve these problems. If any of the algorithms do not suit you, you can implement your own just by satisfying the defined interface.\n\n📦 Installation\n---------------\n\nIt's best to use [Composer](https://getcomposer.org) for installation, and you can also find the package on\n[Packagist](https://packagist.org/packages/baraja-core/variable-generator) and\n[GitHub](https://github.com/baraja-core/variable-generator).\n\nTo install, simply use the command:\n\n```\n$ composer require baraja-core/variable-generator\n```\n\nYou can use the package manually by creating an instance of the internal classes, or register a DIC extension to link the services directly to the Nette Framework.\n\nHow to use\n----------\n\nAt the beginning, create an instance of the Generator or get it from the DIC. If you are using Doctrine entities, there is an autoconfiguration that will automatically find your entity with an order (must meet the `OrderEntity` interface) and you can start generating numbers.\n\nExample:\n\n```php\n$generator = new VariableGenerator(\n\tvariableLoader, // last used variable loader, default is DefaultOrderVariableLoader\n\tstrategy, // generator strategy, default is YearPrefixIncrementStrategy\n\tentityManager, // if you want use default variable loader by Doctrine entity\n);\n```\n\nThe generator is easy to use.\n\nRetrieve the next free number (using it without an argument automatically retrieves the last used number based on the variableLoader service).\n\n```php\necho $generator-\u003egenerate();\n```\n\nGetting the next available number based on the user's choice:\n\n```php\necho $generator-\u003egenerate(21010034); // next will be 21010035\n```\n\nRetrieving the last generated number:\n\n```php\necho $generator-\u003egetCurrent();\n```\n\nYou can always choose your own strategy for generating numbers:\n\n```php\n$generator-\u003esetStrategy();\n```\n\nProtection duplicate number generation\n--------------------------------------\n\nThis tool automatically protects you from generating a duplicate number. To protect you, an automatic lock (see the `baraja-core/lock` library for more information) is used, which allows only one number to be generated at a time, while competing processes in other threads are suspended in the meantime.\n\n📄 License\n-----------\n\n`baraja-core/variable-generator` is licensed under the MIT license. See the [LICENSE](https://github.com/baraja-core/variable-generator/blob/master/LICENSE) file for more details.\n","funding_links":["https://github.com/sponsors/janbarasek","https://brj.app","https://baraja.cz","https://php.baraja.cz"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaraja-core%2Fvariable-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaraja-core%2Fvariable-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaraja-core%2Fvariable-generator/lists"}