Skip to content

Commit

Permalink
Merge pull request #57 from ankurk91/github-actions
Browse files Browse the repository at this point in the history
chore: replace travis-ci with gh-actions
  • Loading branch information
jenssegers committed Dec 20, 2021
2 parents ed1468d + b102f81 commit 564c3ef
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/.github export-ignore
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml export-ignore
38 changes: 38 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: tests

on:
push:
pull_request:

jobs:
test:

runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
php: [7.4, 8.0]
composer-flag: [prefer-lowest, prefer-stable]

name: php v${{ matrix.php }} - ${{ matrix.composer-flag }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pdo, bcmath, gmp
tools: composer:v2

- name: Install dependencies
run: composer update --${{ matrix.composer-flag }} --no-interaction --no-progress

- name: Execute tests
run: |
mkdir -p build/logs
composer test -- --coverage-clover build/logs/clover.xml
[ -f build/logs/clover.xml ] && ./vendor/bin/php-coveralls -v || echo 'clover.xml not found.'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/vendor
/build/
composer.lock
/.phpunit.result.cache
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Jens Segers
Copyright (c) 2021 Jens Segers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
46 changes: 24 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
Optimus id transformation
=========================

[![Latest Stable Version](http://img.shields.io/github/release/jenssegers/optimus.svg)](https://packagist.org/packages/jenssegers/optimus) [![Build Status](http://img.shields.io/travis/jenssegers/optimus.svg)](https://travis-ci.org/jenssegers/optimus) [![Coverage Status](http://img.shields.io/coveralls/jenssegers/optimus.svg)](https://coveralls.io/r/jenssegers/optimus?branch=master)
# Optimus id transformation

[![Packagist](https://badgen.net/packagist/v/jenssegers/optimus)](https://packagist.org/packages/jenssegers/optimus)
[![Downloads](https://badgen.net/packagist/dt/jenssegers/optimus)](https://packagist.org/packages/jenssegers/optimus/stats)
[![Build](https://github.com/jenssegers/optimus/workflows/tests/badge.svg)](https://github.com/jenssegers/optimus/actions)
[![Coverage](http://img.shields.io/coveralls/jenssegers/optimus.svg)](https://coveralls.io/r/jenssegers/optimus?branch=master)

With this library, you can transform your internal id's to obfuscated integers based on Knuth's integer hash. It is similar to Hashids, but will generate integers instead of random strings. It is also super fast.

<p align="center">
<img src="https://jenssegers.com/static/media/optimus.png">
</p>

Installation
------------
## Installation

Install using composer:

```
```bash
composer require jenssegers/optimus
```

If you will be running your code on a 32 bit system or will be working with large prime numbers it is suggested that you install the [GMP extension](http://php.net/manual/en/book.gmp.php). For debian/ubuntu you can install the extension with one of these commands:
If you will be running your code on a 32 bit system or will be working with large prime numbers it is suggested that you install the [GMP extension](http://php.net/manual/en/book.gmp.php).
For debian/ubuntu you can install the extension with one of these commands:

```
```bash
apt-get install php7.0-gmp
apt-get install php7.1-gmp
apt-get install php7.2-gmp
apt-get install php7.3-gmp
apt-get install php7.4-gmp
```

Usage
-----
## Usage

To get started you will need 3 things;

Expand All @@ -38,7 +40,7 @@ To get started you will need 3 things;

Luckily for you, I have included a console command that can do all of this for you. To get started, just run the following command:

```
```bash
> php vendor/bin/optimus spark

Prime: 2123809381
Expand All @@ -48,7 +50,7 @@ Random: 146808189

If you prefer to choose your own prime number (from [this list](http://primes.utm.edu/lists/small/millions/) for example), you can pass it to the command to calculate the remaining numbers:

```
```bash
> php vendor/bin/optimus spark 1580030173

Prime: 1580030173
Expand Down Expand Up @@ -135,16 +137,16 @@ More information: https://laravel.com/docs/5.3/container#resolving

**Third-party integrations**

An integration with Laravel is provided by the [propaganistas/laravel-fakeid](https://packagist.org/packages/propaganistas/laravel-fakeid) package.

Laravel Optimus with multiple connections provided by the [cybercog/laravel-optimus](https://github.com/cybercog/laravel-optimus) package.

An integration with Silex 2 is provided by the [jaam/silex-optimus-provider](https://packagist.org/packages/jaam/silex-optimus-provider) package.

An integration with Laravel is provided by the [elfsundae/laravel-hashid](https://github.com/ElfSundae/laravel-hashid) package.

A PSR-15 middleware provided by the [icanhazstring/optimus-middleware](https://github.com/icanhazstring/optimus-middleware) package.
* An integration with Laravel is provided by the [propaganistas/laravel-fakeid](https://packagist.org/packages/propaganistas/laravel-fakeid) package.
* Laravel Optimus with multiple connections provided by the [cybercog/laravel-optimus](https://github.com/cybercog/laravel-optimus) package.
* An integration with Silex 2 is provided by the [jaam/silex-optimus-provider](https://packagist.org/packages/jaam/silex-optimus-provider) package.
* An integration with Laravel is provided by the [elfsundae/laravel-hashid](https://github.com/ElfSundae/laravel-hashid) package.
* A PSR-15 middleware provided by the [icanhazstring/optimus-middleware](https://github.com/icanhazstring/optimus-middleware) package.

## Security contact information

To report a security vulnerability, follow [these steps](https://tidelift.com/security).

## License

The [MIT](https://opensource.org/licenses/MIT) License.
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,12 @@
"suggest": {
"ext-gmp": "Required for 32bit systems"
},
"bin": ["bin/optimus"]
"bin": ["bin/optimus"],
"config": {
"sort-packages": true,
"preferred-install": "dist"
},
"scripts": {
"test": "vendor/bin/phpunit --testdox --color=always"
}
}
12 changes: 6 additions & 6 deletions tests/EnergonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public function testGeneratesRandomSet(int $bitLength)
$set = Energon::generate(null, $bitLength);

$this->assertCount(3, $set);
$this->assertInternalType('integer', $set[0], 'Unexpected type for prime number.');
$this->assertInternalType('integer', $set[1], 'Unexpected type for inverse number.');
$this->assertInternalType('integer', $set[2], 'Unexpected type for Xor.');
$this->assertIsInt($set[0], 'Unexpected type for prime number.');
$this->assertIsInt($set[1], 'Unexpected type for inverse number.');
$this->assertIsInt($set[2], 'Unexpected type for Xor.');
$this->assertSame(
'1',
(new BigInteger($set[0]))
Expand Down Expand Up @@ -70,9 +70,9 @@ public function testGeneratesAskedSet(int $bitLength, int $prime, int $expectedI
$set = Energon::generate($prime, $bitLength);

$this->assertCount(3, $set);
$this->assertInternalType('integer', $set[0], 'Unexpected type for prime number.');
$this->assertInternalType('integer', $set[1], 'Unexpected type for inverse number.');
$this->assertInternalType('integer', $set[2], 'Unexpected type for Xor.');
$this->assertIsInt($set[0], 'Unexpected type for prime number.');
$this->assertIsInt($set[1], 'Unexpected type for inverse number.');
$this->assertIsInt($set[2], 'Unexpected type for Xor.');
$this->assertEquals($prime, $set[0], 'Unexpected prime number.');
$this->assertEquals($expectedInverse, $set[1], 'Unexpected inverse number.');
}
Expand Down

0 comments on commit 564c3ef

Please sign in to comment.