Skip to content

Commit

Permalink
Merge pull request #1 from rlmckenney/master
Browse files Browse the repository at this point in the history
PSR-4 autoloading with namespaces
  • Loading branch information
Grandiere Antoine authored Jun 10, 2017
2 parents 71c9fd2 + 866e3b4 commit 70d9fb6
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ php:

install: composer install

script: php vendor/bin/phpunit tests.php
script: php vendor/bin/phpunit tests
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ composer require sightengine/client-php

You will need your API USER and API SECRET to initialize the client. You can find both of them on your Sightengine account.
```php
require __DIR__ . '/vendor/autoload.php';
use Sightengine\SightenginClient;

$client = new SightengineClient('{api_user}', '{api_secret}');
```
Expand All @@ -34,26 +34,26 @@ Several moderation engines are available for you to choose from (nudity detectio
```php
# Detect nudity in an image

$output = $client->check('nudity')->image('http://img09.deviantart.net/2bd0/i/2009/276/c/9/magic_forrest_wallpaper_by_goergen.jpg')
$output = $client->check(['nudity'])->image('http://img09.deviantart.net/2bd0/i/2009/276/c/9/magic_forrest_wallpaper_by_goergen.jpg')

# Detect nudity, weapons, alcohol, drugs and faces in an image, along with image properties and type
$output = $client->check('nudity', 'type', 'properties', 'wad', 'face')->image('http://img09.deviantart.net/2bd0/i/2009/276/c/9/magic_forrest_wallpaper_by_goergen.jpg')
# Detect nudity, weapons, alcohol, drugs, likely fruadulant users, celebrities and faces in an image, along with image properties and type
$output = $client->check(['nudity', 'type', 'properties', 'wad', 'face', 'scam', 'celebrity'])->image('http://img09.deviantart.net/2bd0/i/2009/276/c/9/magic_forrest_wallpaper_by_goergen.jpg')
```

## Moderate a local image:
```php
# Detect nudity in an image
$output = $client->check('nudity')->image('/full/path/to/image.jpg')
$output = $client->check(['nudity'])->image('/full/path/to/image.jpg')

# Detect nudity, weapons, alcohol, drugs and faces in an image, along with image properties and type
$output = $client->check('nudity', 'type', 'properties', 'wad', 'face')->image('/full/path/to/image.jpg')
$output = $client->check(['nudity', 'type', 'properties', 'wad', 'face'])->image('/full/path/to/image.jpg')
```

# Video and Stream Moderation
The first step to detect nudity in a video stream is to submit the video stream to the API.

```php
$client->check('nudity')->video('http://www.quirksmode.org/html5/videos/big_buck_bunny.webm', 'https://example.com/yourcallback')
$client->check(['nudity'])->video('http://www.quirksmode.org/html5/videos/big_buck_bunny.webm', 'https://example.com/yourcallback')
```

# Feedback
Expand Down
32 changes: 19 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
{
"name": "sightengine/client-php",
"description": "Sightengine PHP client",
"homepage": "https://sightengine.com",
"authors": [
{
"name": "Sightengine",
"homepage": "https://sightengine.com"
}
],
"require-dev": {
"phpunit/phpunit": "^5.7"
},
"require": {
"guzzlehttp/guzzle": "~6.0"
"description": "Sightengine PHP client",
"homepage": "https://sightengine.com",
"authors": [
{ "name": "Sightengine", "homepage": "https://sightengine.com" },
{ "name": "Robert McKenney", "email": "[email protected]" }
],

"require-dev": {
"phpunit/phpunit": "^5.7"
},

"require": {
"guzzlehttp/guzzle": "~6.0"
},

"autoload": {
"psr-4": {
"Sightengine\\": "src/"
}
}
}
8 changes: 3 additions & 5 deletions check.php → src/Check.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
require __DIR__ . '/vendor/autoload.php';
<?php
namespace Sightengine;

class Check {
private $api_user;
Expand Down Expand Up @@ -39,6 +39,4 @@ public function video($videoUrl, $callbackUrl) {

return json_decode($r->getBody());
}
}

?>
}
13 changes: 4 additions & 9 deletions sightengine.php → src/SightengineClient.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php

require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/check.php';
<?php
namespace Sightengine;

class SightengineClient {
private $api_user;
private $api_secret;
private $endpoint = 'https://api.sightengine.com/';
private $http;
private $http;

function __construct($api_user, $api_secret) {
$this->api_user = $api_user;
Expand All @@ -34,7 +32,4 @@ public function feedback($model, $modelClass, $image) {
public function check($models) {
return new Check($this->api_user, $this->api_secret, $models);
}
}


?>
}
6 changes: 4 additions & 2 deletions tests.php → tests/StackTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
use PHPUnit\Framework\TestCase;
require __DIR__ . '/sightengine.php';
namespace Tests;

use \PHPUnit\Framework\TestCase;
use \Sightengine\SightengineClient;

class StackTest extends TestCase
{
Expand Down
File renamed without changes

0 comments on commit 70d9fb6

Please sign in to comment.