{"id":45687871,"url":"https://github.com/hichemtab-tech/namecrement-php","last_synced_at":"2026-02-24T15:35:15.347Z","repository":{"id":290429382,"uuid":"974414651","full_name":"HichemTab-tech/Namecrement-php","owner":"HichemTab-tech","description":"A smart php utility that generates unique incremental names, preventing naming collisions by automatically appending incremental suffixes.","archived":false,"fork":false,"pushed_at":"2025-09-02T23:52:59.000Z","size":114,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-03T00:25:22.020Z","etag":null,"topics":["incremental","php","unique","unique-name"],"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/HichemTab-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"buy_me_a_coffee":"hichemtabtech","github":"hichemtab-tech"}},"created_at":"2025-04-28T18:35:08.000Z","updated_at":"2025-09-02T23:03:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"eff2b064-10be-4b94-b27d-b0f74bf5ed93","html_url":"https://github.com/HichemTab-tech/Namecrement-php","commit_stats":null,"previous_names":["hichemtab-tech/namecrement-php"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/HichemTab-tech/Namecrement-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HichemTab-tech%2FNamecrement-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HichemTab-tech%2FNamecrement-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HichemTab-tech%2FNamecrement-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HichemTab-tech%2FNamecrement-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HichemTab-tech","download_url":"https://codeload.github.com/HichemTab-tech/Namecrement-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HichemTab-tech%2FNamecrement-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29788137,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T10:45:18.109Z","status":"ssl_error","status_checked_at":"2026-02-24T10:45:09.911Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["incremental","php","unique","unique-name"],"created_at":"2026-02-24T15:35:10.086Z","updated_at":"2026-02-24T15:35:15.341Z","avatar_url":"https://github.com/HichemTab-tech.png","language":"PHP","funding_links":["https://buymeacoffee.com/hichemtabtech","https://github.com/sponsors/hichemtab-tech"],"categories":[],"sub_categories":[],"readme":"# Namecrement (PHP)\n\n\u003c!--suppress HtmlDeprecatedAttribute --\u003e\n\u003cp align=\"center\"\u003e\n\n![Tests](https://github.com/HichemTab-tech/Namecrement-php/workflows/Tests/badge.svg)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/HichemTab-tech/Namecrement-php/blob/master/LICENSE)\n![Packagist Version](https://img.shields.io/packagist/v/hichemtab-tech/namecrement)\n\n\u003c/p\u003e\n\n**Smart unique name generator for PHP**  \nAutomatically generates a unique name by incrementing it if needed — just like `\"file\" → \"file (1)\" → \"file (2)\"` and so on.\n\n---\n\n## ✨ Features\n\n- Generate unique names based on existing ones\n- Smart gap detection (fills missing indexes first)\n- Lightweight, dependency-free\n- Perfect for filenames, labels, IDs, and more\n\n---\n\n### 📦 Also Available\n\n* JavaScript: [Namecrement](https://github.com/HichemTab-tech/Namecrement)\n* Python: [Namecrement-py](https://github.com/HichemTab-tech/Namecrement-py)\n\n## 📦 Installation\n\n```bash\ncomposer require hichemtab-tech/namecrement-php\n```\n\n---\n\n## 🚀 Usage\n\n```php\n\u003c?php\n\nuse HichemTabTech\\Namecrement\\Namecrement;\n\n$existing = ['file', 'file (1)', 'file (2)'];\n$newName = Namecrement::namecrement('file', $existing);\n\necho $newName; \n// Outputs: \"file (3)\"\n```\n---\n\n## 🧠 Advanced Usage\n\nYou can customize the suffix format using the `%N%` placeholder to define how the number is added:\n\n```php\nNamecrement::namecrement('file', ['file', 'file -1-', 'file -2-'], ' -%N%-');\n// ➔ 'file -3-'\n\nNamecrement::namecrement('version', ['version', 'version\u003cv1\u003e'], '\u003cv%N%\u003e');\n// ➔ 'version\u003cv2\u003e'\n```\n\n### 🛡 Suffix Format Rules\n\n- The `suffixFormat` **must include** `%N%`, or an `InvalidArgumentException` will be thrown.\n- `%N%` will be replaced by the next available number.\n- Default format is `\" (%N%)\"`.\n\n| Format Example    | Result              |\n|-------------------|---------------------|\n| `\" (%N%)\"`        | `file (1)`          |\n| `-%N%`            | `file-1`            |\n| `_\u003cv%N%\u003e`         | `file_\u003cv1\u003e`         |\n| `_%N%_`           | `file_1_`           |\n\n---\n\n## 📚 API\n\n### `namecrement(string $baseName, array $existingNames): string`\n\n| Parameter        | Type          | Description                                          |\n|------------------|---------------|------------------------------------------------------|\n| `baseName`       | string        | Proposed name to start from                          |\n| `existingNames`  | string[]      | List of already existing names                       |\n| `suffixFormat`   | string        | Optional format for suffix (optional)                |\n| `startingNumber` | `int \\| null` | The starting number for incrementing (default: null) |\n\nReturns the next available **unique name**.\n\n---\n\n## 🛠 Examples\n\n```php\nNamecrement::namecrement('report', ['report', 'report (1)']);\n// ➔ 'report (2)'\n\nNamecrement::namecrement('image', ['photo', 'image', 'image (1)', 'image (2)']);\n// ➔ 'image (3)'\n\nNamecrement::namecrement('new', []);\n// ➔ 'new'\nNamecrement::namecrement('file', ['file', 'file (1)', 'file (2)'], ' -%N%-');\n// ➔ 'file -1-'\n\nNamecrement::namecrement('file', [], startingNumber: 5);\n// → 'file (5)'\n```\n\n---\n\n## 📄 License\n\nThis project is open-source and available under the [MIT license](LICENSE).\n\n---\n\n## 🤝 Contributing\n\nContributions are welcome!  \nPlease check out the [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhichemtab-tech%2Fnamecrement-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhichemtab-tech%2Fnamecrement-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhichemtab-tech%2Fnamecrement-php/lists"}