Skip to content

Commit e45804c

Browse files
committed
Refactored to use namespaces and PSR-4 autoload
1 parent 71c9fd2 commit e45804c

File tree

6 files changed

+31
-30
lines changed

6 files changed

+31
-30
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

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)