Skip to content

Commit d239320

Browse files
committed
initial commit
0 parents  commit d239320

File tree

8 files changed

+2080
-0
lines changed

8 files changed

+2080
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vendor
2+
runTest.bat

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2023 Hassan Azzi
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# AlphaID
2+
3+
AlphaID let you convert any integer to a short alphanumeric version. It can be useful for generating short, unique, and obfuscated identifiers.
4+
5+
## Requirements
6+
7+
PHP 7.3 and later.
8+
9+
## Installation (Composer)
10+
11+
You can install the bindings via [Composer](http://getcomposer.org/). Run the following command:
12+
13+
```bash
14+
composer require devknown/alpha-id
15+
```
16+
17+
To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
18+
19+
```php
20+
require_once('vendor/autoload.php');
21+
```
22+
23+
## Getting Started
24+
25+
Simple usage looks like:
26+
27+
```php
28+
29+
// convert number to a short string
30+
echo \Devknown\AlphaID::convert(258456357951); // Output: '4y7exoH'
31+
32+
// recover the original number from the short string
33+
echo \Devknown\AlphaID::recover('4y7exoH'); // Output: 258456357951
34+
35+
```
36+
37+
Convert with key:
38+
39+
```php
40+
use Devknown\AlphaID;
41+
42+
AlphaID::config('my_key');
43+
44+
echo AlphaID::convert(258456357951);
45+
// the output this time will be '4ymMZq9'
46+
47+
echo AlphaID::recover('4ymMZq9');
48+
// the recover output this time will be 258456357951
49+
50+
```
51+
52+
## License
53+
54+
AlphaID is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).

composer.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "devknown/alpha-id",
3+
"type": "library",
4+
"description": "Convert any integer to a short alphanumeric version.",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Hassan Azzi",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"require": {
13+
"php": ">=7.3"
14+
},
15+
"require-dev": {
16+
"phpunit/phpunit": "^9.5"
17+
},
18+
"autoload": {
19+
"psr-4": { "Devknown\\": "src/Devknown/" }
20+
}
21+
}

0 commit comments

Comments
 (0)