Skip to content

Commit

Permalink
Merge 84b2ff8 into 6813fd2
Browse files Browse the repository at this point in the history
  • Loading branch information
Nenglish7 committed Apr 4, 2018
2 parents 6813fd2 + 84b2ff8 commit e10352b
Show file tree
Hide file tree
Showing 17 changed files with 190 additions and 110 deletions.
3 changes: 3 additions & 0 deletions .coveralls.yml
@@ -0,0 +1,3 @@
service_name: travis-ci
coverage_clover: ./build/logs/clover.xml
json_path: ./build/logs/coveralls-upload.json
11 changes: 11 additions & 0 deletions .editorconfig
@@ -0,0 +1,11 @@
; top-most EditorConfig file
root = true

; Unix-style newlines
[*]
end_of_line = LF

; Indention style
[*.php]
indent_style = space
indent_size = 4
5 changes: 4 additions & 1 deletion .gitignore
@@ -1,6 +1,9 @@
/build/
/vendor/
/composer.phar
/composer.lock
/tests/phpunit.phar
/tests/phpunit.phar.asc
/.editorconfig
/phpunit.xml
/phpunit.xml.dist
/psalm.xml
3 changes: 1 addition & 2 deletions .php_cs
Expand Up @@ -13,5 +13,4 @@ return Symfony\CS\Config::create()
->finder(
Symfony\CS\Finder\DefaultFinder::create()
->in(__DIR__)
)
;
);
12 changes: 10 additions & 2 deletions .travis.yml
Expand Up @@ -16,9 +16,17 @@ os:
- linux
install:
- travis_retry composer install --no-interaction
- wget -c -nc --retry-connrefused --tries=0 https://github.com/php-coveralls/php-coveralls/releases/download/v2.0.0/php-coveralls.phar
- chmod +x php-coveralls.phar
- php php-coveralls.phar --version
after_success:
- travis_retry php php-coveralls.phar -v
before_script:
- mkdir -p build/logs
- ls -al
script:
- ./vendor/bin/phpcs --standard=psr2 src/
- ./vendor/bin/phpunit --coverage-text
- ./vendor/bin/phpcs --standard=psr2 ./src
- ./vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml
- ./vendor/bin/psalm
cache:
directories:
Expand Down
13 changes: 7 additions & 6 deletions README.md
Expand Up @@ -5,6 +5,7 @@
[![Latest Unstable Version](https://poser.pugx.org/paragonie/easydb/v/unstable)](https://packagist.org/packages/paragonie/easydb)
[![License](https://poser.pugx.org/paragonie/easydb/license)](https://packagist.org/packages/paragonie/easydb)
[![Downloads](https://img.shields.io/packagist/dt/paragonie/easydb.svg)](https://packagist.org/packages/paragonie/easydb)
[![Coverage Status](https://coveralls.io/repos/github/paragonie/easydb/badge.svg?branch=master)](https://coveralls.io/github/paragonie/easydb?branch=master)

PDO lacks brevity and simplicity; EasyDB makes separating data from instructions
easy (and aesthetically pleasing).
Expand Down Expand Up @@ -40,15 +41,15 @@ middle of a `mysql_query()` statement. Let's make it secure.
### The PDO Way

```php
$db = new \PDO(
$db = new PDO(
'mysql:host=localhost;dbname=something',
'username',
'putastrongpasswordhere'
);

$statement = $db->prepare('SELECT * FROM comments WHERE blogpostid = ? ORDER BY created ASC');
$exec = $statement->execute([$_GET['blogpostid']]);
$rows = $exec->fetchAll(\PDO::FETCH_ASSOC);
$rows = $exec->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) {
$template_engine->render('comment', $row);
}
Expand All @@ -60,7 +61,7 @@ we end up repeating ourselves a lot.
### The EasyDB Solution

```php
$db = \ParagonIE\EasyDB\Factory::create(
$db = ParagonIE\EasyDB\Factory::create(
'mysql:host=localhost;dbname=something',
'username',
'putastrongpasswordhere'
Expand Down Expand Up @@ -101,7 +102,7 @@ $sql = $db->buildInsertQuery('comments', [
$result = $db->q(
$sql,
$values,
\PDO::FETCH_BOTH,
PDO::FETCH_BOTH,
true
);
```
Expand Down Expand Up @@ -154,7 +155,7 @@ $exists = $db->single(
```php
$save = function (EasyDB $db) use ($userData, $query) {
$db->safeQuery($query, [$userData['userId']]);
\Some\Other\Package::CleanUpTable($db);
Some\Other\Package::CleanUpTable($db);
};
// auto starts, commits and rolls back a transaction as necessary
$db->tryFlatTransaction($save);
Expand Down Expand Up @@ -230,7 +231,7 @@ $pdo = $db->getPdo();
**Yes!** It's as simple as doing this:

```php
$easy = new \ParagonIE\EasyDB\EasyDB($pdo, 'mysql');
$easy = new ParagonIE\EasyDB\EasyDB($pdo, 'mysql');
```

## How do I run tests ?
Expand Down
55 changes: 24 additions & 31 deletions composer.json
@@ -1,64 +1,57 @@
{
"name": "paragonie/easydb",
"description": "Easy-to-use database abstraction",
"name": "paragonie/easydb",
"description": "Easy-to-use database abstraction.",
"homepage": "https://paragonie.com/",
"keywords": [
"database",
"PDO",
"sql",
"security"
],
"license": "MIT",
"type": "library",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "Scott Arciszewski",
"email": "scott@paragonie.com",
"name": "Scott Arciszewski",
"email": "scott@paragonie.com",
"homepage": "https://paragonie.com",
"role": "Developer"
"role": "Develop"
},
{
"name": "Woody Gilk",
"homepage": "https://github.com/shadowhand",
"role": "Contributor"
},
{
"name": "SignpostMarv",
"homepage": "https://github.com/SignpostMarv",
"role": "Contributor"
"name": "EasyDB Contributors",
"homepage": "https://github.com/paragonie/easydb/graphs/contributors",
"role": "Contribute"
}
],
"support": {
"issues": "https://github.com/paragonie/easydb/issues",
"email": "info@paragonie.com",
"source": "https://github.com/paragonie/easydb"
"email": "info@paragonie.com"
},
"autoload": {
"psr-4": {
"ParagonIE\\EasyDB\\": "src"
"ParagonIE\\EasyDB\\": "./src"
}
},
"autoload-dev": {
"psr-4": {
"ParagonIE\\EasyDB\\Tests\\": "tests"
"ParagonIE\\EasyDB\\Tests\\": "./tests"
}
},
"require": {
"ext-pdo": "*"
},
"require-dev": {
"phpunit/phpunit": "^5",
"spatie/7to5": "^1.0",
"squizlabs/php_codesniffer": "^2.7",
"vimeo/psalm": "^1.0"
"squizlabs/php_codesniffer": "^2",
"phpunit/phpunit": "^6|^7",
"vimeo/psalm": "^1"
},
"scripts": {
"php5ize": [
"php7to5 convert --overwrite --copy-all -- src/ src-php5/",
"php7to5 convert --overwrite --copy-all -- tests/ tests-php5/",
"rm -rf src && mv src-php5 src",
"rm -rf tests && mv tests-php5 tests"
],
"check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests",
"fix-style": "phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests"
}
},
"config": {
"preferred-install": "dist",
"optimize-autoloader": true,
"sort-packages": true
},
"prefer-stable": true
}
32 changes: 20 additions & 12 deletions phpunit.xml.dist
@@ -1,33 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="true"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
bootstrap="./vendor/autoload.php"
cacheTokens="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
syntaxCheck="true">
<testsuite name="paragonie/easydb Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
stopOnIncomplete="false"
stopOnSkipped="false"
stopOnRisky="false"
failOnRisky="true"
failOnWarning="true"
timeoutForSmallTests="1"
timeoutForMediumTests="10"
timeoutForLargeTests="60"
verbose="false">
<testsuites>
<testsuite name="paragonie/easydb Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
<directory>./build</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-text"
target="php://stdout"
showUncoveredFiles="true"
showOnlySummary="false" />
<log type="coverage-clover" target="./build/logs/clover.xml" />
</logging>
</phpunit>
12 changes: 5 additions & 7 deletions psalm.xml
@@ -1,11 +1,9 @@
<?xml version="1.0"?>
<psalm
name="EasyDB static analysis tests."
stopOnFirstError="false"
useDocblockTypes="true"
totallyTyped="true"
>
<psalm name="EasyDB static analysis tests."
stopOnFirstError="false"
useDocblockTypes="true"
totallyTyped="true">
<projectFiles>
<directory name="src" />
<directory name="./src" />
</projectFiles>
</psalm>
1 change: 1 addition & 0 deletions src/EasyDB.php
Expand Up @@ -1030,6 +1030,7 @@ public function tryFlatTransaction(callable $callback): bool
$this->beginTransaction();
}
try {
/** @psalm-suppress TooManyArguments */
$callback($this);
// If we started the transaction, we should commit here
if ($autoStartTransaction) {
Expand Down
19 changes: 16 additions & 3 deletions src/Exception/ConstructorFailed.php
@@ -1,11 +1,24 @@
<?php
declare(strict_types=1);
/**
* Paragon Initiative Enterprises.
*
* @author Scott Arciszewski <scott@paragonie.com>.
* @author EasyDB Contributors <https://github.com/paragonie/easydb/graphs/contributors>
*
* @link <https://github.com/paragonie/easydb> Github Repository.
* @license <https://github.com/paragonie/easydb/blob/master/LICENSE> MIT License.
*
* @package ParagonIE\EasyDB
*/

namespace ParagonIE\EasyDB\Exception;

use RuntimeException;

/**
* ConstructorFailed.
*
* @package ParagonIE\EasyDB
*/
class ConstructorFailed extends \RuntimeException implements ExceptionInterface
class ConstructorFailed extends RuntimeException implements ExceptionInterface
{
}
19 changes: 16 additions & 3 deletions src/Exception/ExceptionInterface.php
@@ -1,11 +1,24 @@
<?php
declare(strict_types=1);
/**
* Paragon Initiative Enterprises.
*
* @author Scott Arciszewski <scott@paragonie.com>.
* @author EasyDB Contributors <https://github.com/paragonie/easydb/graphs/contributors>
*
* @link <https://github.com/paragonie/easydb> Github Repository.
* @license <https://github.com/paragonie/easydb/blob/master/LICENSE> MIT License.
*
* @package ParagonIE\EasyDB
*/

namespace ParagonIE\EasyDB\Exception;

use Throwable;

/**
* ExceptionInterface.
*
* @package ParagonIE\EasyDB
*/
interface ExceptionInterface
interface ExceptionInterface extends Throwable
{
}
19 changes: 16 additions & 3 deletions src/Exception/InvalidIdentifier.php
@@ -1,11 +1,24 @@
<?php
declare(strict_types=1);
/**
* Paragon Initiative Enterprises.
*
* @author Scott Arciszewski <scott@paragonie.com>.
* @author EasyDB Contributors <https://github.com/paragonie/easydb/graphs/contributors>
*
* @link <https://github.com/paragonie/easydb> Github Repository.
* @license <https://github.com/paragonie/easydb/blob/master/LICENSE> MIT License.
*
* @package ParagonIE\EasyDB
*/

namespace ParagonIE\EasyDB\Exception;

use InvalidArgumentException;

/**
* InvalidIdentifier.
*
* @package ParagonIE\EasyDB
*/
class InvalidIdentifier extends \InvalidArgumentException implements ExceptionInterface
class InvalidIdentifier extends InvalidArgumentException implements ExceptionInterface
{
}
19 changes: 16 additions & 3 deletions src/Exception/QueryError.php
@@ -1,11 +1,24 @@
<?php
declare(strict_types=1);
/**
* Paragon Initiative Enterprises.
*
* @author Scott Arciszewski <scott@paragonie.com>.
* @author EasyDB Contributors <https://github.com/paragonie/easydb/graphs/contributors>
*
* @link <https://github.com/paragonie/easydb> Github Repository.
* @license <https://github.com/paragonie/easydb/blob/master/LICENSE> MIT License.
*
* @package ParagonIE\EasyDB
*/

namespace ParagonIE\EasyDB\Exception;

use RuntimeException;

/**
* QueryError.
*
* @package ParagonIE\EasyDB
*/
class QueryError extends \RuntimeException implements ExceptionInterface
class QueryError extends RuntimeException implements ExceptionInterface
{
}

0 comments on commit e10352b

Please sign in to comment.