Skip to content

Commit

Permalink
upgrade php
Browse files Browse the repository at this point in the history
  • Loading branch information
maztch committed Feb 24, 2022
1 parent 407ba7b commit 1641a92
Show file tree
Hide file tree
Showing 21 changed files with 291 additions and 1,334 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: php

php:
- '7.3'
- '7.4'
- '8.0'
- '8.1'


before_script: composer install
20 changes: 20 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
Changelog
---------


v1.2.2

* Compatibility with php 8.1
* Upgraded php version requirements
* Only composer use mode
* Code cleaned
* Improved exception messages

v1.2.1

* New tool editpdf added

v1.1.18

* Php 8 compatibility
* Upgraded php version requirements
* Added Watermark with images
* Improved download to browser method

v1.0.11

* Bug AuthException warning
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
machine:
php:
version: 7.3
version: 7.4
15 changes: 12 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,19 @@
}
},
"require": {
"php": ">=7.3",
"ext-curl": "*"
"php": ">=7.4",
"ext-curl": "*",
"ext-openssl": "*",
"firebase/php-jwt": "^6.0",
"guzzlehttp/guzzle": "^7.4"
},
"require-dev": {
"phpunit/phpunit": "^9.4"
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^4.21"
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true
}
}
}
42 changes: 0 additions & 42 deletions init.php

This file was deleted.

15 changes: 0 additions & 15 deletions phpunit.no_autoload.xml

This file was deleted.

15 changes: 15 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<psalm
errorLevel="7"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
13 changes: 1 addition & 12 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ Develop and automate PDF processing tasks like Compress PDF, Merge PDF, Split PD

## Requirements

PHP 7.3 and later.
PHP 7.4 and later.

## Install

### Using composer

You can install the library via [Composer](http://getcomposer.org/). Run the following command:

```bash
Expand All @@ -32,15 +30,6 @@ To use the library, use Composer's [autoload](https://getcomposer.org/doc/00-int
require_once('vendor/autoload.php');
```


### Manual Installation

If you do not wish to use Composer, you can download the [latest release](https://github.com/ilovepdf/ilovepdf-php/releases). Then, to use the library, include the `init.php` file.

```php
require_once('/path/to/ilovepdf-php/init.php');
```

## Getting Started

Simple usage looks like:
Expand Down
2 changes: 1 addition & 1 deletion src/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function setText($text)
}

/**
* @param strig $image
* @param string $image
*/
public function setImage($image)
{
Expand Down
16 changes: 10 additions & 6 deletions src/Exceptions/ExtendedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ class ExtendedException extends Exception
* @param string $message
* @param int $code
* @param Exception|null $previous
* @param $response
* @param $responseBody
*/
public function __construct($message, $response, $code = 0, Exception $previous = null)
public function __construct($message, $responseBody, $code = 0, $previous = null)
{
if (isset($response->body->error) && $response->body->error->type) {
$this->type = $response->body->error->type;
if(!$code){$code = 0;}
if (isset($responseBody->error) && $responseBody->error->type) {
$this->type = $responseBody->error->type;
}
if (isset($response->body->error->param)) {
$this->params = $response->body->error->param;
if (isset($responseBody->error->param)) {
$this->params = $responseBody->error->param;
}
if ($this->params) {
if (is_array($this->params)) {
Expand Down Expand Up @@ -60,6 +61,9 @@ public function __construct($message, $response, $code = 0, Exception $previous
*/
public function getErrors()
{
if(!is_countable($this->params)){
return [];
}
return $this->params;
}

Expand Down
43 changes: 43 additions & 0 deletions src/Http/Client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Ilovepdf\Http;


use Psr\Http\Message\ResponseInterface;

class Client
{
private static $verify = true;
private static $allowRedirects = true;

private $client;

public function __construct(array $params = [])
{
$defaultParams = [
'allow_redirects' => self::$allowRedirects,
'http_errors' => false,
'verify' => self::$verify,
];

$this->client = new \GuzzleHttp\Client(array_merge_recursive($defaultParams, $params));
}

public function request(string $method, $uri = '', array $options = []): ResponseInterface
{
return $this->client->request($method, $uri, $options);
}

public static function setAllowRedirects(bool $follow)
{
self::$allowRedirects = $follow;
}

/**
* @param $verify
*/
public static function setVerify($verify)
{
self::$verify = $verify;
}
}
7 changes: 7 additions & 0 deletions src/Http/ClientException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Ilovepdf\Http;

class ClientException extends \GuzzleHttp\Exception\ClientException
{
}
Loading

0 comments on commit 1641a92

Please sign in to comment.