Skip to content
This repository has been archived by the owner on Jan 2, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/psr-dependencies'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Oct 29, 2018
2 parents 10edf61 + 61f7ea6 commit 2d34566
Show file tree
Hide file tree
Showing 35 changed files with 698 additions and 699 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.markdown
Expand Up @@ -4,6 +4,8 @@ CHANGELOG for the Transifex API Package
* 3.0.0 (201x-xx-xx)

* Raised minimum PHP version to 7.2
* The `Transifex` and `TransifexObject` classes now require a `RequestFactoryInterface` and `UriFactoryInterface` (PSR-17) implementations as constructor arguments
* The `$client` constructor argument of the `Transifex` and `TransifexObject` classes is now a PSR-18 `ClientInterface` and is required

* 2.1.1 (2018-03-10)

Expand Down
8 changes: 3 additions & 5 deletions README.markdown
Expand Up @@ -11,11 +11,9 @@ The *Transifex API Package* is a PHP client for accessing the [Transifex API](ht
Requirements
------------

* Production
* PHP 7.2 or later
* [Guzzle HTTP](https://github.com/guzzle/guzzle) client
* Development
* [PHPUnit](http://phpunit.de/)
* PHP 7.2 or later
* Any [PSR-17 compatible](https://www.php-fig.org/psr/psr-17/) factories
* Any [PSR-18 compatible](https://www.php-fig.org/psr/psr-18/) HTTP client

Documentation
-------------
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Expand Up @@ -13,10 +13,13 @@
"require": {
"php": "~7.2",
"ext-json": "*",
"guzzlehttp/guzzle": "^6.2.1"
"psr/http-client": "~0.3",
"psr/http-factory": "~1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.13",
"guzzlehttp/guzzle": "^6.3.3",
"http-interop/http-factory-guzzle": "~1.0",
"phpunit/phpunit": "~7.0"
},
"autoload": {
Expand Down
8 changes: 2 additions & 6 deletions docs/classes/Formats.md
Expand Up @@ -7,18 +7,14 @@ The `Formats` class is the interface to Transifex' [formats API](http://docs.tra
An instance of the `Formats` class should be retrieved through the `Transifex` class' `get()` factory.

```php
use BabDev\Transifex\Transifex;

/** @var \BabDev\Transifex\Formats $formats */
$formats = (new Transifex())->get('formats');
$formats = $transifex->get('formats');
```

### Get supported file formats

To retrieve the supported file formats from the Transifex API, call the `Formats::getFormats()` method.

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('formats')->getFormats();
$apiResponse = $transifex->get('formats')->getFormats();
```
12 changes: 3 additions & 9 deletions docs/classes/Languageinfo.md
Expand Up @@ -7,10 +7,8 @@ The `Languageinfo` class is the interface to Transifex' [language info API](http
An instance of the `Languageinfo` class should be retrieved through the `Transifex` class' `get()` factory.

```php
use BabDev\Transifex\Transifex;

/** @var \BabDev\Transifex\Languageinfo $formats */
$languageInfo = (new Transifex())->get('languageinfo');
$languageInfo = $transifex->get('languageinfo');
```

### Get information on a supported language
Expand All @@ -22,17 +20,13 @@ This method has one required parameter:
* The language code to retrieve (string)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languageinfo')->getLanguage('en-US');
$apiResponse = $transifex->get('languageinfo')->getLanguage('en-US');
```

### Get information on all supported languages

To retrieve information about all supported languages from the Transifex API, call the `Languageinfo::getLanguages()` method.

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languageinfo')->getLanguages();
$apiResponse = $transifex->get('languageinfo')->getLanguages();
```
52 changes: 13 additions & 39 deletions docs/classes/Languages.md
Expand Up @@ -7,10 +7,8 @@ The `Languages` class is the interface to Transifex' [languages API](http://docs
An instance of the `Languages` class should be retrieved through the `Transifex` class' `get()` factory.

```php
use BabDev\Transifex\Transifex;

/** @var \BabDev\Transifex\Languages $languages */
$languages = (new Transifex())->get('languages');
$languages = $transifex->get('languages');
```

### Create a language for a project
Expand All @@ -29,9 +27,7 @@ This method also has two optional parameters to pass additional information:
* A boolean flag that if true, the API call does not fail and instead will return a list of invalid usernames (boolean, default false)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languages')->createLanguage('my-project', 'en-US', ['mbabker']);
$apiResponse = $transifex->get('languages')->createLanguage('my-project', 'en-US', ['mbabker']);
```

The API requires at least one username to be provided. If the coordinators array is empty, an `\InvalidArgumentException` is thrown.
Expand All @@ -46,9 +42,7 @@ This method has two required parameters:
* The language code for the language to delete (string)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languages')->deleteLanguage('my-project', 'en-US');
$apiResponse = $transifex->get('languages')->deleteLanguage('my-project', 'en-US');
```

### Get the coordinators for a project's language
Expand All @@ -61,9 +55,7 @@ This method has two required parameters:
* The language code for the language to query (string)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languages')->getCoordinators('my-project', 'en-US');
$apiResponse = $transifex->get('languages')->getCoordinators('my-project', 'en-US');
```

### Get the details for a project's language
Expand All @@ -76,19 +68,15 @@ This method has two required parameters:
* The language code for the language to query (string)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languages')->getLanguage('my-project', 'en-US');
$apiResponse = $transifex->get('languages')->getLanguage('my-project', 'en-US');
```

This method also has one optional parameter to add the `?details` fragment:

* True to add the `?details` fragment (bool)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languages')->getLanguage('my-project', 'en-US', true);
$apiResponse = $transifex->get('languages')->getLanguage('my-project', 'en-US', true);
```

### Get the project's languages
Expand All @@ -100,9 +88,7 @@ This method has one required parameter:
* The slug for the project (string)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languages')->getLanguages('my-project');
$apiResponse = $transifex->get('languages')->getLanguages('my-project');
```

### Get the reviewers for a project's language
Expand All @@ -115,9 +101,7 @@ This method has two required parameters:
* The language code for the language to query (string)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languages')->getReviewers('my-project', 'en-US');
$apiResponse = $transifex->get('languages')->getReviewers('my-project', 'en-US');
```

### Get the translators for a project's language
Expand All @@ -130,9 +114,7 @@ This method has two required parameters:
* The language code for the language to query (string)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languages')->getTranslators('my-project', 'en-US');
$apiResponse = $transifex->get('languages')->getTranslators('my-project', 'en-US');
```

### Update the coordinators for a project's language
Expand All @@ -150,9 +132,7 @@ This method also has one optional parameter to pass additional information:
* A boolean flag that if true, the API call does not fail and instead will return a list of invalid usernames (boolean, default false)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languages')->updateCoordinators('my-project', 'en-US', ['mbabker']);
$apiResponse = $transifex->get('languages')->updateCoordinators('my-project', 'en-US', ['mbabker']);
```

The API requires at least one username to be provided. If the coordinators array is empty, an `\InvalidArgumentException` is thrown.
Expand All @@ -172,9 +152,7 @@ This method also has one optional parameter to pass additional information:
* An array containing optional additional params to send with the request, this array should contain the 'translators' and 'reviewers' options with the option's name as a key in the array (associative array, defaults to an empty array)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languages')->updateLanguage('my-project', 'en-US', ['mbabker']);
$apiResponse = $transifex->get('languages')->updateLanguage('my-project', 'en-US', ['mbabker']);
```

The API requires at least one username to be provided. If the coordinators array is empty, an `\InvalidArgumentException` is thrown.
Expand All @@ -194,9 +172,7 @@ This method also has one optional parameter to pass additional information:
* A boolean flag that if true, the API call does not fail and instead will return a list of invalid usernames (boolean, default false)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languages')->updateReviewers('my-project', 'en-US', ['mbabker']);
$apiResponse = $transifex->get('languages')->updateReviewers('my-project', 'en-US', ['mbabker']);
```

The API requires at least one username to be provided. If the reviewers array is empty, an `\InvalidArgumentException` is thrown.
Expand All @@ -216,9 +192,7 @@ This method also has one optional parameter to pass additional information:
* A boolean flag that if true, the API call does not fail and instead will return a list of invalid usernames (boolean, default false)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('languages')->updateTranslators('my-project', 'en-US', ['mbabker']);
$apiResponse = $transifex->get('languages')->updateTranslators('my-project', 'en-US', ['mbabker']);
```

The API requires at least one username to be provided. If the translators array is empty, an `\InvalidArgumentException` is thrown.
24 changes: 6 additions & 18 deletions docs/classes/Projects.md
Expand Up @@ -7,10 +7,8 @@ The `Projects` class is the interface to Transifex' [projects API](http://docs.t
An instance of the `Projects` class should be retrieved through the `Transifex` class' `get()` factory.

```php
use BabDev\Transifex\Transifex;

/** @var \BabDev\Transifex\Projects $projects */
$projects = (new Transifex())->get('projects');
$projects = $transifex->get('projects');
```

### Create a project
Expand All @@ -29,9 +27,7 @@ This method also has one optional parameter to pass additional information:
* An array containing optional additional params to send with the request, this array should contain all additional options not specified in the method's other parameters (associative array, defaults to an empty array)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('projects')->createProject('My Project', 'my-project', 'This is my new project', 'en-US');
$apiResponse = $transifex->get('projects')->createProject('My Project', 'my-project', 'This is my new project', 'en-US');
```

Transifex requires that open source projects specify a repository URL. If this is not present, an `\InvalidArgumentException` will be thrown.
Expand All @@ -47,9 +43,7 @@ This method has one required parameter:
* The slug for the project (string)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('projects')->deleteProject('my-project');
$apiResponse = $transifex->get('projects')->deleteProject('my-project');
```

### Get information about a project
Expand All @@ -65,9 +59,7 @@ This method also has one additional optional parameter:
* A flag to retrieve additional project details (boolean, defaults to false)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('projects')->getProject('my-project');
$apiResponse = $transifex->get('projects')->getProject('my-project');
```

### Get the projects the authenticated user is a member of
Expand All @@ -77,9 +69,7 @@ To get the list of projects the authenticated user is a member of, call the `Pro
This method has no parameters.

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('projects')->getProjects();
$apiResponse = $transifex->get('projects')->getProjects();
```

### Update a project
Expand All @@ -92,9 +82,7 @@ This method has two required parameters:
* An array containing the project details to update (associative array)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('projects')->updateProject('my-project', ['name' => 'My Project']);
$apiResponse = $transifex->get('projects')->updateProject('my-project', ['name' => 'My Project']);
```

If the data array is empty, a `\RuntimeException` is thrown. If the project's license is updated and is not an allowed value, an `\InvalidArgumentException` is thrown.
28 changes: 7 additions & 21 deletions docs/classes/Resources.md
Expand Up @@ -7,10 +7,8 @@ The `Resources` class is the interface to Transifex' [resources API](http://docs
An instance of the `Resources` class should be retrieved through the `Transifex` class' `get()` factory.

```php
use BabDev\Transifex\Transifex;

/** @var \BabDev\Transifex\Resources $resources */
$resources = (new Transifex())->get('resources');
$resources = $transifex->get('resources');
```

### Create a resource
Expand All @@ -31,9 +29,7 @@ This method also has one optional parameter to pass additional information:
NOTE: To upload contents for this resource, this method allows either a filename or a string containing the contents. The filename should be passed in the 'file' key of the options array and the string contents passed in the 'content' key.

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('resources')->createResource('my-project', 'Resource 1', 'resource-1', 'INI');
$apiResponse = $transifex->get('resources')->createResource('my-project', 'Resource 1', 'resource-1', 'INI');
```

If a filename has been provided and the file does not exist, an `\InvalidArgumentException` is thrown.
Expand All @@ -48,9 +44,7 @@ This method has two required parameters:
* The slug for the resource (string)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('resources')->deleteResource('my-project', 'resource-1');
$apiResponse = $transifex->get('resources')->deleteResource('my-project', 'resource-1');
```

### Get information about a resource
Expand All @@ -67,9 +61,7 @@ This method also has one additional optional parameter:
* A flag to retrieve additional project details (boolean, defaults to false)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('resources')->getResource('my-project', 'resource-1');
$apiResponse = $transifex->get('resources')->getResource('my-project', 'resource-1');
```

### Get a resource's contents
Expand All @@ -82,9 +74,7 @@ This method has two required parameters:
* The slug for the resource (string)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('resources')->getResourceContent('my-project', 'resource-1');
$apiResponse = $transifex->get('resources')->getResourceContent('my-project', 'resource-1');
```

### Get the list of the project's resources
Expand All @@ -96,9 +86,7 @@ This method has one required parameter:
* The slug for the project (string)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('resources')->getResources('my-project');
$apiResponse = $transifex->get('resources')->getResources('my-project');
```

### Update a resource's content
Expand All @@ -116,9 +104,7 @@ This method also has one additional optional parameter:
* The resource type provided in the third parameter, must be either 'string' or 'file' (string)

```php
use BabDev\Transifex\Transifex;

$apiResponse = (new Transifex())->get('resources')->updateResourceContent('my-project', 'resource-1', 'TEST="My Test String"');
$apiResponse = $transifex->get('resources')->updateResourceContent('my-project', 'resource-1', 'TEST="My Test String"');
```

If a filename has been provided and the file does not exist, an `\InvalidArgumentException` is thrown.

0 comments on commit 2d34566

Please sign in to comment.