Skip to content

Commit

Permalink
session validator client
Browse files Browse the repository at this point in the history
Co-authored-by: Józsa Csongor <[email protected]>
  • Loading branch information
knagy and Józsa Csongor committed Aug 2, 2018
1 parent 6ebcee6 commit d77cf0c
Show file tree
Hide file tree
Showing 16 changed files with 2,625 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.gitignore export-ignore
/.travis.yml export-ignore
/tests/ export-ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: php
php:
- 5.6
- 7.0
- 7.1
install:
- composer install
script:
- composer style
- composer test
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Emarsys Technologies Ltd.

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.
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,49 @@
# session-validator-client-php
# session-validator-client-php ![Build status](https://travis-ci.org/emartech/session-validator-client-php.svg?branch=master)

PHP client for Emarsys session validator service

## Install

```bash
composer require emartech/session-validator-client
```

## Usage

### Validating a single MSID

```php
$client = Client::create('https://service-url', 'escher_key', 'escher_secret');

var_dump($client->isValid('msid'));
```

### Batch validating multiple MSIDs

Returns an array of the invalid MSIDs.

```php
$client = Client::create('https://service-url', 'escher_key', 'escher_secret');

var_dump($client->filterInvalid(['msid1', 'msid2']));
```

### Caching results

```php
$client = Client::create('https://service-url', 'escher_key', 'escher_secret');
$cachedClient = CachedClient::create($client);

var_dump($cachedClient->isValid('msid'));
```

### Logging

To enable logging, add a PSR-3 compatible logger to the client

```php
use Monolog\Logger;

$client = Client::create('https://service-url', 'escher_key', 'escher_secret');
$client->setLogger(new Logger('name'));
```
43 changes: 43 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "emartech/session-validator-client",
"description": "PHP client for Emarsys session validator service",
"homepage": "https://github.com/emartech/session-validator-client-php",
"authors": [
{
"name": "Emarsys Technologies",
"homepage": "https://www.emarsys.com/",
"role": "company"
}
],
"license": [
"MIT"
],
"type": "library",
"autoload": {
"psr-4": {
"SessionValidator\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Test\\SessionValidator\\": "tests/"
}
},
"require": {
"php": ">=5.6",
"emartech/escher": "^1.1",
"guzzlehttp/guzzle": "^6.3",
"psr/log": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^3.3"
},
"suggest": {
"ext-apcu": "Needed to support APC cache"
},
"scripts": {
"style": "vendor/bin/phpcs --standard=PSR2 src/ tests/",
"test": "vendor/bin/phpunit --bootstrap=vendor/autoload.php tests/"
}
}
Loading

0 comments on commit d77cf0c

Please sign in to comment.