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

Feat: Major version up #3

Merged
merged 1 commit into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
coverage_clover: tests/_output/coverage.xml
json_path: tests/_output/coveralls-upload.json
coverage_clover: build/logs/clover.xml
json_path: build/logs/coveralls-upload.json
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/vendor/
/composer.lock

tests/_output/*
.php_cs.cache
.phpunit.result.cache
composer.lock
48 changes: 48 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

use PhpCsFixer\Config;
use Symfony\Component\Finder\Finder;

$finder = (new Finder())
->path('*.php')
->exclude(['vendor'])
->in(__DIR__);

$rules = [
'@Symfony' => true,
'align_multiline_comment' => ['comment_type' => 'phpdocs_like'],
'array_syntax' => ['syntax' => 'short'],
'blank_line_before_statement' => false,
'cast_spaces' => ['space' => 'none'],
'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'],
'heredoc_to_nowdoc' => true,
'list_syntax' => null,
'no_extra_consecutive_blank_lines' => ['tokens' => ['continue', 'parenthesis_brace_block', 'extra', 'return']],
'no_multiline_whitespace_before_semicolons' => true,
'no_null_property_initialization' => true,
'no_short_echo_tag' => false,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => false,
'no_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'not_operator_with_space' => false,
'not_operator_with_successor_space' => false,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_annotation_without_dot' => null,
'phpdoc_no_alias_tag' => false,
'phpdoc_no_empty_return' => false,
'phpdoc_order' => true,
'phpdoc_separation' => false,
'phpdoc_summary' => null,
'phpdoc_types_order' => true,
'return_type_declaration' => true,
'void_return' => false,
'yoda_style' => false,
];

return Config::create()
->setRules($rules)
->setFinder($finder);
14 changes: 6 additions & 8 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
checks:
php:
code_rating: true
duplication: true

filter:
excluded_paths:
- tests/*
- examples/*
- vendor/*

build:

environment:
php: '7.0.8'
php: '7.4'

dependencies:
before:
- 'composer install'
- './vendor/bin/codecept build'
- composer install
- mkdir -p build/logs

tests:
override:
-
command: 'php vendor/bin/codecept run unit --coverage --coverage-xml'
command: 'phpdbg -qrr vendor/bin/phpunit --coverage-clover build/logs/clover.xml'
coverage:
file: 'tests/_output/coverage.xml'
format: 'php-clover'
file: 'build/logs/clover.xml'
format: 'clover'
24 changes: 10 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
language: php

php:
- 7.0.8

install:
- composer install
- ./vendor/bin/codecept build

sudo: false
- 7.1
- 7.2
- 7.3
- 7.4

cache:
directories:
- ./vendor
- $HOME/.composer/cache

script:
- php vendor/bin/codecept run unit --coverage --coverage-xml
before_script:
- mkdir -p build/logs

branches:
only:
- master
script:
- phpdbg -qrr vendor/bin/phpunit --coverage-clover build/logs/clover.xml

after_script:
- travis_retry php vendor/bin/coveralls
after_success:
- travis_retry php vendor/bin/php-coveralls -v
85 changes: 57 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,57 @@
# EasyCrypt [![Build Status](https://travis-ci.org/mpyw/EasyCrypt.svg?branch=master)](https://travis-ci.org/mpyw/EasyCrypt) [![Coverage Status](https://coveralls.io/repos/github/mpyw/EasyCrypt/badge.svg?branch=master)](https://coveralls.io/github/mpyw/EasyCrypt?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mpyw/EasyCrypt/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mpyw/EasyCrypt/?branch=master)

A class that provides simple interface for **decryptable** encryption.

## Installing

```
composer install mpyw/easycrypt:^3.0
```

## Usage

```php
<?php

require __DIR__ . '/vendor/autoload.php';
use mpyw\EasyCrypt\Cryptor;

$cryptor = new Cryptor;

$secret_data = '[Secret Data]';
$password = '[Password]';

$encrypted = $cryptor->encrypt($secret_data, $password);
$decrypted = $cryptor->decrypt($enctypred, $password);

var_dump($secret_data === $decrypted); // bool(true)
```
# EasyCrypt [![Build Status](https://travis-ci.com/mpyw/EasyCrypt.svg?branch=master)](https://travis-ci.com/mpyw/EasyCrypt) [![Coverage Status](https://coveralls.io/repos/github/mpyw/EasyCrypt/badge.svg?branch=master)](https://coveralls.io/github/mpyw/EasyCrypt?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mpyw/EasyCrypt/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mpyw/EasyCrypt/?branch=master)

A class that provides simple interface for **decryptable** encryption.

## Installing

```
composer install mpyw/easycrypt
```

## Usage

### Basic

```php
<?php

use Mpyw\EasyCrypt\Cryptor;

$cryptor = new Cryptor;

$secretData = '[Secret Data]';
$password = '[Password]';

$encrypted = $cryptor->encrypt($secretData, $password);
$decrypted = $cryptor->decrypt($encrypted, $password); // String on success, false on failure.

var_dump($secretData === $decrypted); // bool(true)
```

### Throw `DecryptionFailedException` when decryption failed

It throws `DecryptionFailedException` instead of returning false.

```php
$decrypted = $cryptor->mustDecrypt($encrypted, $password);
```

### Use fixed password

You can use `FixedPasswordCryptor` instead of raw `Cryptor`.
This is useful when we use a fixed password from an application config.

```php
<?php

use Mpyw\EasyCrypt\FixedPasswordCryptor;

$cryptor = new FixedPasswordCryptor('[Password]');

$secretData = '[Secret Data]';

$encrypted = $cryptor->encrypt($secretData);
$decrypted = $cryptor->decrypt($encrypted); // String on success, false on failure.

var_dump($secretData === $decrypted); // bool(true)
```
27 changes: 0 additions & 27 deletions codeception.yml

This file was deleted.

26 changes: 11 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,24 @@
],
"autoload": {
"psr-4": {
"mpyw\\EasyCrypt\\": "src/"
"Mpyw\\EasyCrypt\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Mpyw\\EasyCrypt\\Tests\\": "tests/"
}
},
"require": {
"php": ">=5.4.0",
"php": "^7.1",
"ext-openssl": "*"
},
"require-dev": {
"php": ">=7.0.0",
"codeception/codeception": "^2.2",
"satooshi/php-coveralls": "^1.0"
"php": "^7.1",
"friendsofphp/php-cs-fixer": "^2.16",
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": "^8.5"
},
"scripts": {
"test": [
"php vendor/bin/codecept run unit --coverage --coverage-xml"
]
},
"archive": {
"exclude": [
"*",
".*",
"!/src/*"
]
}
}
22 changes: 22 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
bootstrap="vendor/autoload.php"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
Loading