Skip to content

Commit ee86311

Browse files
committed
add capability to offload images to optimole
1 parent dda54f4 commit ee86311

22 files changed

+1325
-4
lines changed

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,19 @@
1616
},
1717
"require": {
1818
"php": ">=7.4",
19+
"ext-json": "*",
1920
"symfony/polyfill-php80": "^1.29"
2021
},
2122
"require-dev": {
2223
"friendsofphp/php-cs-fixer": "^3.0",
24+
"guzzlehttp/guzzle": "^7.0",
25+
"php-stubs/wordpress-stubs": "^6.5",
2326
"phpstan/phpstan": "^1.0",
24-
"phpunit/phpunit": "^9.6"
27+
"phpunit/phpunit": "^9.6",
28+
"szepeviktor/phpstan-wordpress": "^1.3"
29+
},
30+
"suggest": {
31+
"guzzlehttp/guzzle": "Use the Guzzle HTTP client to make requests to the API"
2532
},
2633
"config": {
2734
"optimize-autoloader": true,

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
includes:
2+
- ./vendor/szepeviktor/phpstan-wordpress/extension.neon
13
parameters:
24
level: 5
35
paths:

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
2+
<phpunit bootstrap="tests/bootstrap.php"
33
backupGlobals="false"
44
backupStaticAttributes="false"
55
colors="true"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of Optimole PHP SDK.
7+
*
8+
* (c) Optimole Team <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Optimole\Sdk\Exception;
15+
16+
class BadResponseException extends RuntimeException
17+
{
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of Optimole PHP SDK.
7+
*
8+
* (c) Optimole Team <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Optimole\Sdk\Exception;
15+
16+
class DashboardApiException extends BadResponseException
17+
{
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of Optimole PHP SDK.
7+
*
8+
* (c) Optimole Team <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Optimole\Sdk\Exception;
15+
16+
class InvalidDashboardApiResponseException extends DashboardApiException
17+
{
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of Optimole PHP SDK.
7+
*
8+
* (c) Optimole Team <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Optimole\Sdk\Exception;
15+
16+
class InvalidUploadApiResponseException extends UploadApiException
17+
{
18+
}

src/Exception/UploadApiException.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of Optimole PHP SDK.
7+
*
8+
* (c) Optimole Team <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Optimole\Sdk\Exception;
15+
16+
class UploadApiException extends BadResponseException
17+
{
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of Optimole PHP SDK.
7+
*
8+
* (c) Optimole Team <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Optimole\Sdk\Exception;
15+
16+
class UploadFailedException extends RuntimeException
17+
{
18+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of Optimole PHP SDK.
7+
*
8+
* (c) Optimole Team <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Optimole\Sdk\Exception;
15+
16+
use Optimole\Sdk\ValueObject\OffloadUsage;
17+
18+
class UploadLimitException extends UploadApiException
19+
{
20+
/**
21+
* The offload service usage.
22+
*/
23+
private OffloadUsage $usage;
24+
25+
/**
26+
* Constructor.
27+
*/
28+
public function __construct(OffloadUsage $usage, string $message = '', int $code = 0, ?\Throwable $previous = null)
29+
{
30+
parent::__construct($message, $code, $previous);
31+
32+
$this->usage = $usage;
33+
}
34+
35+
/**
36+
* Get the offload service usage.
37+
*/
38+
public function getUsage(): OffloadUsage
39+
{
40+
return $this->usage;
41+
}
42+
}

0 commit comments

Comments
 (0)