Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update packages #18

Merged
merged 16 commits into from
Apr 1, 2019
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

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

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
28 changes: 16 additions & 12 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/tests export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs export-ignore
/.php_cs.dist export-ignore
/.scrutinizer.yml export-ignore
/.sensiolabs.yml export-ignore
/.styleci.yml export-ignore
/.travis.yml export-ignore
/phpunit.xml export-ignore
/phpunit.xml.dist export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs export-ignore
/.php_cs.dist export-ignore
/.scrutinizer.yml export-ignore
/.sensiolabs.yml export-ignore
/.styleci.yml export-ignore
/.travis.yml export-ignore
/docs export-ignore
/ISSUE_TEMPLATE.md export-ignore
/phpcs.xml.dist export-ignore
/phpunit.xml export-ignore
/phpunit.xml.dist export-ignore
/PULL_REQUEST_TEMPLATE.md export-ignore
/tests export-ignore
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
.DS_Store
Thumbs.db
/vendor
/build
composer.phar
composer.lock
.php_cs.cache
/phpunit.xml
.phpunit.result.cache
/.idea
/.vscode
7 changes: 4 additions & 3 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
build:
nodes:
analysis:
project_setup:
override: true
tests:
override: [php-scrutinizer-run]

filter:
excluded_paths:
- "tests/"
excluded_paths: [tests/*]

checks:
php:
Expand All @@ -26,5 +27,5 @@ checks:

tools:
external_code_coverage:
timeout: 1200
timeout: 600
runs: 4
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@ dist: trusty
language: php

php:
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm
- 7.3

# This triggers builds to run on the new TravisCI infrastructure.
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false

## Cache composer
cache:
directories:
- $HOME/.composer/cache

matrix:
include:
- php: 5.6
env: 'COMPOSER_FLAGS="--prefer-lowest --prefer-stable"'
- php: 7.1
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'

before_script:
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist --no-suggest
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist

script:
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover

after_script:
- |
if [[ "$TRAVIS_PHP_VERSION" != 'hhvm' && "$TRAVIS_PHP_VERSION" != '7.0' ]]; then
if [[ "$TRAVIS_PHP_VERSION" != 'hhvm' ]]; then
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
fi
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release Notes

## unreleased

- Removed PHP 5 support
- Added support for Laravel 5.7 and 5.8
- Added support for `tuupola/base62` 2.x
- Added support for `hashids/hashids` 3.x
- Added support for `jenssegers/optimus` 1.x

## 1.2.0 (2018-02-04)

- Support Laravel 5.6
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
}
],
"require": {
"php": ">=5.6.4",
"illuminate/support": "~5.0,<5.7",
"illuminate/console": "~5.0,<5.7",
"tuupola/base62": "~0.9",
"php": "~7.1",
"illuminate/support": "~5.0,<5.9",
"illuminate/console": "~5.0,<5.9",
"tuupola/base62": "~2.0",
"elfsundae/urlsafe-base64": "~1.1",
"hashids/hashids": "^2.0.4",
"jenssegers/optimus": "^0.2.3",
"hashids/hashids": "^2.0.4|~3.0",
"jenssegers/optimus": "~1.0",
"phpseclib/phpseclib": "~2.0"
},
"require-dev": {
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~5.7|~6.0|~7.0",
"phpunit/phpunit": "~5.7|~6.0|~7.0|~8.0",
"orchestra/testbench": "~3.0",
"paragonie/random_compat": "~1.0|~2.0"
},
Expand Down
3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
Expand Down
17 changes: 5 additions & 12 deletions src/Base62Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ class Base62Driver implements DriverInterface
*/
protected $base62;

/**
* Indicates integer encoding.
*
* @var bool
*/
protected $integer = false;

/**
* Create a new Base62 driver instance.
*
Expand All @@ -38,22 +31,22 @@ public function __construct(array $config = [])
/**
* Encode the data.
*
* @param mixed $data
* @param string $data
* @return string
*/
public function encode($data)
{
return $this->base62->encode($data, $this->integer);
return $this->base62->encode($data);
}

/**
* Decode the data.
*
* @param mixed $data
* @return mixed
* @param string $data
* @return string
*/
public function decode($data)
{
return $this->base62->decode($data, $this->integer);
return $this->base62->decode($data);
}
}
21 changes: 18 additions & 3 deletions src/Base62IntegerDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,24 @@
class Base62IntegerDriver extends Base62Driver
{
/**
* Indicates integer encoding.
* Encode the data.
*
* @var bool
* @param int $data
* @return string
*/
protected $integer = true;
public function encode($data)
{
return $this->base62->encodeInteger($data);
}

/**
* Decode the data.
*
* @param string $data
* @return int
*/
public function decode($data)
{
return $this->base62->decodeInteger($data);
}
}
6 changes: 2 additions & 4 deletions tests/Base62DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public function testInstantiation()
public function testEncoding()
{
$this->assertEncodedData('Hashid', 'Mb6pKATc');
$this->runForRandomBytes();
$this->runForLeadingZeroBytes();
$this->runForBytes();
$this->assertUniformEncoding(random_bytes(128));

$this->assertEncodedData(987654321, '14q60P', $this->integerDriver);
Expand All @@ -33,8 +32,7 @@ public function testEncodingWithCustomCharacters()
$config = [
'characters' => str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'),
];
$this->runForRandomBytes($config);
$this->runForLeadingZeroBytes($config);
$this->runForBytes();
$this->assertUniformEncoding(random_bytes(128), $config);
$this->runForIntegers($this->integerDriver, $config);
$this->assertUniformEncoding(random_int(0, PHP_INT_MAX), $this->integerDriver, $config);
Expand Down
2 changes: 1 addition & 1 deletion tests/OptimusDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class OptimusDriverTest extends DriverTestCase
{
protected $driver = OptimusDriver::class;

protected $maxInteger = Optimus::MAX_INT;
protected $maxInteger = 2 ** Optimus::DEFAULT_SIZE - 1;

public function testInstantiation()
{
Expand Down