Skip to content

Commit

Permalink
Refactored for PHP7 as PSR-4 Class
Browse files Browse the repository at this point in the history
  • Loading branch information
lastguest committed Oct 10, 2017
1 parent 8eb0648 commit 4fb7516
Show file tree
Hide file tree
Showing 12 changed files with 2,453 additions and 73 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

[*.php]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

[*.md]
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.editorconfig export-ignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.DS_Store
._.DS_Store
vendor/
20 changes: 20 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2011-2017 Stefano Azzolini.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ PHP Implementation of MurmurHash3

More information about these algorithms can be found at:

* [MurmurHash Homepage](http://sites.google.com/site/murmurhash/)
* [Wikipedia Entry on MurmurHash](http://en.wikipedia.org/wiki/MurmurHash)
* [MurmurHash Homepage](http://sites.google.com/site/murmurhash/)
* [Wikipedia Entry on MurmurHash](http://en.wikipedia.org/wiki/MurmurHash)

Porting of the MurmurHash3 JavaScript version created by Gary Court (https://github.com/garycourt/murmurhash-js)

## Installation

Use [composer](https://getcomposer.org/download/) :

```bash
Expand All @@ -20,19 +21,32 @@ composer require lastguest/murmurhash

## Usage

You can retrieve an hash via `hash3` static method of class `Murmur`

```php
<?php
echo murmurhash3("Hello World");
use lastguest\Murmur;

echo Murmur::hash3("Hello World");
// cnd0ue
```

You can pass a precise seed positive integer as second parameter

## License (MIT)
```php
<?php
use lastguest\Murmur;

Copyright (c) 2011 Stefano Azzolini
echo Murmur::hash3("Hello World", 1234567);
// qtq2u
```

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
If you need the integer hash, use the `hash3_int` method

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
```php
<?php
use lastguest\Murmur;

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
echo Murmur::hash3_int("Hello World");
// 427197390
```
34 changes: 26 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
{
"name": "lastguest/murmurhash",
"type": "library",
"description": "MurmurHash3 Hash",
"homepage": "https://github.com/lastguest/murmurhash-php",
"keywords": [ "hash","hashing", "murmur" ],
"type": "library",
"keywords": [
"hash",
"hashing",
"murmur"
],
"license": "MIT",
"require": {
"php": ">=4.3"
},
"authors": [
{
"name": "Stefano Azzolini",
"email": "lastguest@gmail.com",
"homepage": "https://github.com/lastguest/murmurhash-php"
}
],
"scripts": {
"test" : [
"vendor/bin/phpstan analyse --ansi -n -c tests/phpstan.neon -l 5 src",
"vendor/bin/phpunit --colors=always -c tests/phpunit.xml tests/cases"
]
},
"config": {
"optimize-autoloader": true,
"classmap-authoritative": true
},
"require": {
"php": "^7"
},
"require-dev": {
"phpunit/phpunit": "^5",
"phpstan/phpstan": "^0.6.3"
},
"minimum-stability": "stable",
"autoload": {
"files": [
"murmurhash3.php"
]
"psr-4": {
"lastguest\\": "src/lastguest/"
}
}
}

0 comments on commit 4fb7516

Please sign in to comment.