Skip to content

Commit

Permalink
Lid changes for v1.x, readme update, psr12
Browse files Browse the repository at this point in the history
  • Loading branch information
choval committed Mar 13, 2020
1 parent ffecc4f commit e475504
Show file tree
Hide file tree
Showing 7 changed files with 4,306 additions and 1,013 deletions.
89 changes: 58 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
LID (LongID) is a 64-bit number used to identify rows in a database.
Made specifically for use with BIGINT/LONGINT in databases. Includes a checksum to verify data.

Note: v1.x is not compatible with v0.x.

## Install

```sh
composer require choval/lid
composer require choval/lid^1.0
```

## Format
Expand All @@ -21,26 +23,38 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ

* Except the web format, see <a href="#web">Web</a>.

The checksum is in the first character.
The checksum (Damm) is the first character.

### Examples

```
NUM: 9223372036854775807
WEB: 75FE-KXVC-3KT2-6XC7
LID: 7aZl:8N0y:58M7
WEB: 75FE_KXVC_3KP2_6XC7
LID: 7aZl-8N0y-58M7
NUM: 8057322199735401981
WEB: 94V7-27T8-8CT6-54X1
LID: 99Bc:CvJ3:BrCR
WEB: 94V7_27P8_8CP6_54X1
LID: 99Bc-CvJ3-BrCR
NUM: 495653535173419733
WEB: 9061-03H6-471H-T96H
LID: 90AC:66ri:lnk9
WEB: 961_3H6_471H_P96H
LID: 9AC-66ri-lnk9
NUM: 3412381023195
WEB: 0_6H_5V91_7PXK
LID: 0-Y4L-x15V
NUM: 8954382094
WEB: 2_6XV4_PK4J
LID: 2-9L-ZFPE
NUM: 21398
WEB: 1000-0000-0000-2H9V
LID: 1000:0000:05z8
WEB: 1_2H9V
LID: 1-5z8
NUM: 1024
WEB: 4_2E4
LID: 4-gw
```


Expand All @@ -55,25 +69,25 @@ Alias characters are replaced.

```
0 - zero - alias: OoDQ
1 - one - alias: Iil
1 - one - alias: IiLl
2 - two - alias: Zz
3 - three
4 - four - alias: AYy
5 - five - alias: Ss
6 - six - alias: Gbh
7 - seven - alias:
6 - six - alias: Gb
7 - seven - alias: T
8 - eight - alias: BRg
9 - nine - alias: q
C - charlie
E - echo
F - foxtrot
H - hotel
J - juliett
K - kilo
N - november - alias: Mm
T - tango - alias: Pp
C - charlie - alias c
E - echo - alias e
F - foxtrot - alias f
H - hotel - alias h
J - juliett - alias j
K - kilo - alias k
N - november - alias: Mmn
P - tango - alias: p
V - victor - alias: UuWw
X - xray
X - xray - alias x
```

## Usage
Expand All @@ -84,31 +98,44 @@ X - xray
*/
$lid = new Lid( 21398 );
echo $lid->id();
// 1000:0000:05z8
// 1-5z8
echo $lid->web();
// 1000-0000-0000-2H9V
// 1_2H9V
echo $lid->number();
// 21398

/**
* The constructor accepts an int, a LID or a Web LID
*/
$lid = new Lid( '1000-0000-0000-2H9V' );
$lid = new Lid( '1_2H9V' );
echo $lid->id();
// 1000:0000:05z8
// 1-5z8
echo $lid->web();
// 1000-0000-0000-2H9V
// 1_2H9V
echo $lid->number();
// 21398


/**
* The constructor accepts long formats as well
*/
$lid = new Lid( '1000_0000_0000_2H9V' );
echo $lid->id();
// 1-5z8
echo $lid->web();
// 1_2H9V
echo $lid->number();
// 21398


/**
* Notice how we pass characters not in the base.
* And the web format allows you to make mistakes with letters and nums
*/
$lid = new Lid( '1ooo-oOoo-ooo0-zHqU' );
$lid = new Lid( '1_zHqU' );
echo $lid->id();
// 1000:0000:05z8
// 1-5z8
echo $lid->web();
// 1000-0000-0000-2H9V
// 1_2H9V
echo $lid->number();
// 21398
```
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
}
],
"autoload": {
"psr-4": {
"Choval\\": "src/"
}
"psr-4": {
"Choval\\": "src/"
}
},
"require": {
"choval/base_convert": "^0.1.1",
"choval/damm": "^0.1.0"
},
"require-dev": {
"phpunit/phpunit": "^7"
"symplify/easy-coding-standard": "^7.0",
"phpunit/phpunit": "^8"
}
}
Loading

0 comments on commit e475504

Please sign in to comment.