Skip to content

Commit bf24b63

Browse files
committed
Add test case .
1 parent 4ed3fe4 commit bf24b63

File tree

9 files changed

+123
-2956
lines changed

9 files changed

+123
-2956
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
run-tests.php

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: php
2+
3+
php:
4+
- 7.0
5+
- 7.1
6+
- 7.2
7+
8+
notifications:
9+
email: false
10+
11+
#Compile
12+
before_script:
13+
- ./travis/compile.sh
14+
15+
# Run PHPs run-tests.php
16+
script:
17+
- ./travis/run-test.sh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ hex.
7878
$hashids = new Hashids();
7979

8080
$hash = $hashids->encodeHex('FFFFDD'); // rYKPAK
81-
$numbers = $hashids->decodeHex($hash); // FFFFDD
81+
$hex = $hashids->decodeHex($hash); // FFFFDD
8282
```
8383

8484
Curses! #$%@

hashids.php

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
<?php
2-
//encode
3-
echo (new Hashids())->encode(1, 2, 3, 4, 5) . "\n";
4-
echo (new Hashids())->encode([1, 2, 3, 4, 5]) . "\n";
2+
3+
$hashids = new Hashids();
4+
5+
$hash = $hashids->encode(1, 2, 3, 4, 5); // ADf9h9i0sQ
6+
$numbers = $hashids->decode($hash); // [1, 2, 3, 4, 5]
7+
8+
echo $hash;
9+
print_r($numbers);
10+
11+
//or would you prefer to use a static method call
12+
$hash = Hashids::encode(1, 2, 3, 4, 5); // ADf9h9i0sQ
13+
$numbers = Hashids::decode($hash); // [1, 2, 3, 4, 5]
14+
15+
echo $hash;
16+
print_r($numbers);
17+
518
//decode
6-
var_dump((new Hashids())->decode("ADf9h9i0sQ"));
19+
$numbers = $hashids->decode("ADf9h9i0sQ");
20+
print_r($numbers);
21+
722
//encodeHex
8-
echo (new Hashids('hhhhh', 30))->encodeHex('C0FFEE') . "\n";
9-
//decodeHex
10-
echo (new Hashids('hhhhh', 30))->decodeHex('xvwLqB4XMbJAEbXxOw6N5lO92YQrKG') . "\n";
23+
$hash = $hashids->encodeHex('FFFFDD'); // rYKPAK
24+
$hex = $hashids->decodeHex('rYKPAK'); // FFFFDD
25+
26+
echo $hash;
27+
echo $hex;

0 commit comments

Comments
 (0)