Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.lock
composer.phar
build/*
vendor/*
*.idea/
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
PHP Trello API v1 client
PHP Trello API v2 client
========================

[![Build Status](https://img.shields.io/travis/cdaguerre/php-trello-api.svg?branch=master&style=flat-square)](https://travis-ci.org/cdaguerre/php-trello-api)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/cdaguerre/php-trello-api/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/cdaguerre/php-trello-api/?branch=master)
[![Code Quality](https://img.shields.io/scrutinizer/g/cdaguerre/php-trello-api.svg?style=flat-square)](https://scrutinizer-ci.com/g/cdaguerre/php-trello-api/)
[![Packagist](https://img.shields.io/packagist/dt/cdaguerre/php-trello-api.svg?style=flat-square)](https://packagist.org/packages/cdaguerre/php-trello-api)

A simple Object Oriented wrapper for the Trello API, written in PHP5.
A simple Object Oriented wrapper for the Trello API, written in PHP7.4.

Uses [Trello API v1](https://trello.com/docs/index.html). The object API is very similar to the RESTful API.

Expand All @@ -15,10 +15,11 @@ Uses [Trello API v1](https://trello.com/docs/index.html). The object API is very
* Follows PSR-0 conventions and coding standards: autoload friendly
* Light and fast thanks to lazy loading of API classes
* Extensively tested
* Ready for Symfony 5

## Requirements

* PHP >= 5.3.2 with [cURL](http://php.net/manual/en/book.curl.php) extension,
* PHP >= 7.4 with [cURL](http://php.net/manual/en/book.curl.php) extension,
* [Guzzle](https://github.com/guzzle/guzzle) library,
* (optional) [PHPUnit](https://phpunit.de) to run tests.

Expand All @@ -27,7 +28,7 @@ Uses [Trello API v1](https://trello.com/docs/index.html). The object API is very
The recommended way is using [composer](http://getcomposer.org):

```bash
$ composer require cdaguerre/php-trello-api:@dev
$ composer require matteocacciola/php-trello-api
```
However, `php-trello-api` follows the PSR-0 naming conventions, which means you can easily integrate `php-trello-api` class loading in your own autoloader.

Expand Down Expand Up @@ -107,5 +108,6 @@ Feel free to make any comments, file issues or make pull requests.

## Credits

- Forked by [cdaguerre/php-trello-api](https://github.com/cdaguerre/php-trello-api)
- Largely inspired by the excellent [php-github-api](https://github.com/KnpLabs/php-github-api) developed by the guys at [KnpLabs](http://knplabs.fr)
- Thanks to Trello for the API and documentation.
14 changes: 9 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
{
"name": "cdaguerre/php-trello-api",
"name": "matteocacciola/php-trello-api",
"type": "library",
"description": "Trello API v1 client",
"homepage": "https://github.com/cdaguerre/php-trello-api",
"description": "Trello API v2 client",
"homepage": "https://github.com/matteocacciola/php-trello-api",
"keywords": ["trello"],
"license": "MIT",
"authors": [
{
"name": "Christian Daguerre",
"email": "[email protected]"
},
{
"name": "Matteo Cacciola",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.3",
"guzzlehttp/guzzle": "~3.7"
"php": ">=7.4",
"guzzlehttp/guzzle": "~5.3"
},
"require-dev": {
"phpunit/phpunit": "^4.8"
Expand Down
86 changes: 43 additions & 43 deletions lib/Trello/Api/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public function __construct(Client $client)
* Catches any undefined "get{$field}" calls, and passes them
* to the getField() if the $field is in the $this->fields property
*
* @param string $method called method
* @param array $arguments array of arguments passed to called method
* @param string $method called method
* @param array $arguments array of arguments passed to called method
*
* @return array
*
Expand Down Expand Up @@ -85,7 +85,7 @@ public function getFields()
/**
* Get a field value by field name
*
* @param string $id the board's id
* @param string $id the board's id
* @param string $field the field
*
* @return mixed field value
Expand All @@ -98,21 +98,21 @@ public function getField($id, $field)
throw new InvalidArgumentException(sprintf('There is no field named %s.', $field));
}

$response = $this->get($this->path.'/'.rawurlencode($id).'/'.rawurlencode($field));
$response = $this->get($this->path . '/' . rawurlencode($id) . '/' . rawurlencode($field));

return isset($response['_value']) ? $response['_value'] : $response;
}

/**
* Send a GET request with query parameters.
*
* @param string $path Request path.
* @param array $parameters GET parameters.
* @param array $requestHeaders Request Headers.
* @param string $path Request path.
* @param array $parameters GET parameters.
* @param array $requestHeaders Request Headers.
*
* @return \Guzzle\Http\EntityBodyInterface|mixed|string
* @return mixed
*/
protected function get($path, array $parameters = array(), $requestHeaders = array())
protected function get($path, array $parameters = [], $requestHeaders = [])
{
$response = $this->client->getHttpClient()->get($path, $parameters, $requestHeaders);

Expand All @@ -122,31 +122,31 @@ protected function get($path, array $parameters = array(), $requestHeaders = arr
/**
* Send a HEAD request with query parameters
*
* @param string $path Request path.
* @param array $parameters HEAD parameters.
* @param array $requestHeaders Request headers.
* @param string $path Request path.
* @param array $parameters HEAD parameters.
* @param array $requestHeaders Request headers.
*
* @return \Guzzle\Http\Message\Response
* @return \GuzzleHttp\Message\Response
*/
protected function head($path, array $parameters = array(), $requestHeaders = array())
protected function head($path, array $parameters = [], $requestHeaders = [])
{
$response = $this->client->getHttpClient()->request($path, null, 'HEAD', $requestHeaders, array(
$response = $this->client->getHttpClient()->request($path, null, 'HEAD', $requestHeaders, [
'query' => $parameters,
));
]);

return $response;
}

/**
* Send a POST request with JSON-encoded parameters.
*
* @param string $path Request path.
* @param array $parameters POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
* @param string $path Request path.
* @param array $parameters POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
*
* @return mixed
*/
protected function post($path, array $parameters = array(), $requestHeaders = array())
protected function post($path, array $parameters = [], $requestHeaders = [])
{
return $this->postRaw(
$path,
Expand All @@ -158,13 +158,13 @@ protected function post($path, array $parameters = array(), $requestHeaders = ar
/**
* Send a POST request with raw data.
*
* @param string $path Request path.
* @param mixed $body Request body.
* @param array $requestHeaders Request headers.
* @param string $path Request path.
* @param mixed $body Request body.
* @param array $requestHeaders Request headers.
*
* @return \Guzzle\Http\EntityBodyInterface|mixed|string
* @return mixed
*/
protected function postRaw($path, $body, $requestHeaders = array())
protected function postRaw($path, $body, $requestHeaders = [])
{
$response = $this->client->getHttpClient()->post(
$path,
Expand All @@ -178,13 +178,13 @@ protected function postRaw($path, $body, $requestHeaders = array())
/**
* Send a PATCH request with JSON-encoded parameters.
*
* @param string $path Request path.
* @param array $parameters POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
* @param string $path Request path.
* @param array $parameters POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
*
* @return mixed
*/
protected function patch($path, array $parameters = array(), $requestHeaders = array())
protected function patch($path, array $parameters = [], $requestHeaders = [])
{
$response = $this->client->getHttpClient()->patch(
$path,
Expand All @@ -198,13 +198,13 @@ protected function patch($path, array $parameters = array(), $requestHeaders = a
/**
* Send a PUT request with JSON-encoded parameters.
*
* @param string $path Request path.
* @param array $parameters POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
* @param string $path Request path.
* @param array $parameters POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
*
* @return mixed
*/
protected function put($path, array $parameters = array(), $requestHeaders = array())
protected function put($path, array $parameters = [], $requestHeaders = [])
{
foreach ($parameters as $name => $parameter) {
if (is_bool($parameter)) {
Expand All @@ -224,13 +224,13 @@ protected function put($path, array $parameters = array(), $requestHeaders = arr
/**
* Send a DELETE request with JSON-encoded parameters.
*
* @param string $path Request path.
* @param array $parameters POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
* @param string $path Request path.
* @param array $parameters POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
*
* @return mixed
*/
protected function delete($path, array $parameters = array(), $requestHeaders = array())
protected function delete($path, array $parameters = [], $requestHeaders = [])
{
$response = $this->client->getHttpClient()->delete(
$path,
Expand Down Expand Up @@ -258,7 +258,7 @@ protected function createParametersBody(array $parameters)
if (is_bool($subParameter)) {
$subParameter = $subParameter ? 'true' : 'false';
}
$parameters[$name.'/'.$subName] = $subParameter;
$parameters[$name . '/' . $subName] = $subParameter;
}
unset($parameters[$name]);
} elseif ($parameter instanceof DateTime) {
Expand All @@ -282,7 +282,7 @@ protected function getPath($id = null)
* Validate parameters array
*
* @param string[] $required required properties (array keys)
* @param array $params array to check for existence of the required keys
* @param array $params array to check for existence of the required keys
*
* @throws MissingArgumentException if a required parameter is missing
*/
Expand All @@ -299,8 +299,8 @@ protected function validateRequiredParameters(array $required, array $params)
* Validate allowed parameters array
* Checks whether the passed parameters are allowed
*
* @param string[] $allowed allowed properties
* @param array|string $params array to check
* @param string[] $allowed allowed properties
* @param array|string $params array to check
* @param string $paramName
*
* @return array array of validated parameters
Expand All @@ -310,7 +310,7 @@ protected function validateRequiredParameters(array $required, array $params)
protected function validateAllowedParameters(array $allowed, $params, $paramName)
{
if (!is_array($params)) {
$params = array($params);
$params = [$params];
}

foreach ($params as $param) {
Expand All @@ -332,7 +332,7 @@ protected function validateAllowedParameters(array $allowed, $params, $paramName
* the keys in a given array
*
* @param string[] $atLeastOneOf allowed properties
* @param array $params array to check
* @param array $params array to check
*
* @return boolean
*
Expand Down
Loading