PluginProbe ʕ •ᴥ•ʔ
TinyPNG – JPEG, PNG & WebP image compression / 2.2.4
TinyPNG – JPEG, PNG & WebP image compression v2.2.4
3.7.0 3.6.14 trunk 1.0.0 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.4.0 1.5.0 1.6.0 1.7.0 1.7.1 1.7.2 2.0.0 2.0.1 2.0.2 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.0.0 3.0.1 3.1.0 3.2.0 3.2.1 3.3 3.4 3.4.1 3.4.2 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.6.0 3.6.1 3.6.10 3.6.11 3.6.12 3.6.13 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9
tiny-compress-images / src / vendor / tinify / Tinify / Exception.php
tiny-compress-images / src / vendor / tinify / Tinify Last commit date
Client.php 9 years ago Exception.php 10 years ago Result.php 10 years ago ResultMeta.php 10 years ago Source.php 10 years ago
Exception.php
37 lines
1 <?php
2
3 namespace Tinify;
4
5 class Exception extends \Exception {
6 public $status;
7
8 public static function create($message, $type, $status) {
9 if ($status == 401 || $status == 403 || $status == 429) {
10 $klass = "Tinify\AccountException";
11 } else if($status >= 400 && $status <= 499) {
12 $klass = "Tinify\ClientException";
13 } else if($status >= 500 && $status <= 599) {
14 $klass = "Tinify\ServerException";
15 } else {
16 $klass = "Tinify\Exception";
17 }
18
19 if (empty($message)) $message = "No message was provided";
20 return new $klass($message, $type, $status);
21 }
22
23 function __construct($message, $type = NULL, $status = NULL) {
24 $this->status = $status;
25 if ($status) {
26 parent::__construct($message . " (HTTP " . $status . "/" . $type . ")");
27 } else {
28 parent::__construct($message);
29 }
30 }
31 }
32
33 class AccountException extends Exception {}
34 class ClientException extends Exception {}
35 class ServerException extends Exception {}
36 class ConnectionException extends Exception {}
37