Skip to content

Commit 70d9fb6

Browse files
author
Grandiere Antoine
authored
Merge pull request #1 from rlmckenney/master
PSR-4 autoloading with namespaces
2 parents 71c9fd2 + 866e3b4 commit 70d9fb6

File tree

7 files changed

+38
-37
lines changed

7 files changed

+38
-37
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ php:
66

77
install: composer install
88

9-
script: php vendor/bin/phpunit tests.php
9+
script: php vendor/bin/phpunit tests

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ composer require sightengine/client-php
1818

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

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

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

39-
# Detect nudity, weapons, alcohol, drugs and faces in an image, along with image properties and type
40-
$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')
39+
# Detect nudity, weapons, alcohol, drugs, likely fruadulant users, celebrities and faces in an image, along with image properties and type
40+
$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')
4141
```
4242

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

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

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

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

5959
# Feedback

composer.json

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
{
22
"name": "sightengine/client-php",
3-
"description": "Sightengine PHP client",
4-
"homepage": "https://sightengine.com",
5-
"authors": [
6-
{
7-
"name": "Sightengine",
8-
"homepage": "https://sightengine.com"
9-
}
10-
],
11-
"require-dev": {
12-
"phpunit/phpunit": "^5.7"
13-
},
14-
"require": {
15-
"guzzlehttp/guzzle": "~6.0"
3+
"description": "Sightengine PHP client",
4+
"homepage": "https://sightengine.com",
5+
"authors": [
6+
{ "name": "Sightengine", "homepage": "https://sightengine.com" },
7+
{ "name": "Robert McKenney", "email": "[email protected]" }
8+
],
9+
10+
"require-dev": {
11+
"phpunit/phpunit": "^5.7"
12+
},
13+
14+
"require": {
15+
"guzzlehttp/guzzle": "~6.0"
16+
},
17+
18+
"autoload": {
19+
"psr-4": {
20+
"Sightengine\\": "src/"
1621
}
22+
}
1723
}

check.php renamed to src/Check.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<?php
2-
require __DIR__ . '/vendor/autoload.php';
1+
<?php
2+
namespace Sightengine;
33

44
class Check {
55
private $api_user;
@@ -39,6 +39,4 @@ public function video($videoUrl, $callbackUrl) {
3939

4040
return json_decode($r->getBody());
4141
}
42-
}
43-
44-
?>
42+
}
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
<?php
2-
3-
require __DIR__ . '/vendor/autoload.php';
4-
require __DIR__ . '/check.php';
1+
<?php
2+
namespace Sightengine;
53

64
class SightengineClient {
75
private $api_user;
86
private $api_secret;
97
private $endpoint = 'https://api.sightengine.com/';
10-
private $http;
8+
private $http;
119

1210
function __construct($api_user, $api_secret) {
1311
$this->api_user = $api_user;
@@ -34,7 +32,4 @@ public function feedback($model, $modelClass, $image) {
3432
public function check($models) {
3533
return new Check($this->api_user, $this->api_secret, $models);
3634
}
37-
}
38-
39-
40-
?>
35+
}

tests.php renamed to tests/StackTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
2-
use PHPUnit\Framework\TestCase;
3-
require __DIR__ . '/sightengine.php';
2+
namespace Tests;
3+
4+
use \PHPUnit\Framework\TestCase;
5+
use \Sightengine\SightengineClient;
46

57
class StackTest extends TestCase
68
{
File renamed without changes.

0 commit comments

Comments
 (0)