Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
21 / 21 |
| Project | |
100.00% |
1 / 1 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
21 / 21 |
| create | |
100.00% |
1 / 1 |
1 | |
100.00% |
7 / 7 |
|||
| edit | |
100.00% |
1 / 1 |
1 | |
100.00% |
4 / 4 |
|||
| getList | |
100.00% |
1 / 1 |
1 | |
100.00% |
6 / 6 |
|||
| getInfo | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| delete | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| <?php | |
| /** | |
| * Crowdin API implementation in PHP. | |
| * | |
| * @copyright Copyright (C) 2016 Nikolai Plath (elkuku) | |
| * @license WTFPL - See license.txt | |
| */ | |
| namespace ElKuKu\Crowdin\Package; | |
| use ElKuKu\Crowdin\ | |
| { | |
| Languageproject, Package | |
| }; | |
| use Psr\Http\Message\ResponseInterface; | |
| /** | |
| * Class Project | |
| * | |
| * @since 1.0.5 | |
| */ | |
| Class Project extends Package | |
| { | |
| /** | |
| * Create Crowdin project. | |
| * | |
| * @param string $login The user login. | |
| * @param string $accountKey The user account key. | |
| * @param Languageproject $project The project object. | |
| * | |
| * @see https://crowdin.com/page/api/create-project | |
| * @since 1.0.7 | |
| * | |
| * @return ResponseInterface | |
| */ | |
| public function create(string $login, string $accountKey, Languageproject $project) : ResponseInterface | |
| { | |
| $path = 'account/create-project?account-key=' . $accountKey; | |
| $params = $project->toQuery(); | |
| $params[] = [ | |
| 'name' => 'login', | |
| 'contents' => $login | |
| ]; | |
| return $this->getHttpClient() | |
| ->post($path, ['multipart' => $params]); | |
| } | |
| /** | |
| * Edit Crowdin project. | |
| * | |
| * @param Languageproject $project The language project object. | |
| * | |
| * @see https://crowdin.com/page/api/edit-project | |
| * @since 1.0.7 | |
| * | |
| * @return ResponseInterface | |
| */ | |
| public function edit(Languageproject $project) : ResponseInterface | |
| { | |
| $project->identifier = null; | |
| $project->source_language = null; | |
| return $this->getHttpClient() | |
| ->post($this->getBasePath('edit-project'), ['multipart' => $project->toQuery()]); | |
| } | |
| /** | |
| * Get Crowdin Project details. | |
| * | |
| * @param string $login Your Crowdin Account login name. | |
| * @param string $accountKey Account API key (profile settings -> "API & SSO" tab). | |
| * | |
| * @see https://crowdin.com/page/api/get-projects | |
| * @since 1.0.7 | |
| * | |
| * @return ResponseInterface | |
| */ | |
| public function getList(string $login, string $accountKey) : ResponseInterface | |
| { | |
| $path = sprintf( | |
| 'account/get-projects?account-key=%s&login=%s', | |
| $accountKey, | |
| $login | |
| ); | |
| return $this->getHttpClient() | |
| ->post($path); | |
| } | |
| /** | |
| * Get Crowdin Project details. | |
| * | |
| * @since 1.0.5 | |
| * @see https://crowdin.com/page/api/info | |
| * | |
| * @return ResponseInterface | |
| */ | |
| public function getInfo() : ResponseInterface | |
| { | |
| return $this->getHttpClient() | |
| ->post($this->getBasePath('info')); | |
| } | |
| /** | |
| * Delete Crowdin project with all translations. | |
| * | |
| * @since 1.0.5 | |
| * @see https://crowdin.com/page/api/delete-project | |
| * | |
| * @return ResponseInterface | |
| */ | |
| public function delete() : ResponseInterface | |
| { | |
| return $this->getHttpClient() | |
| ->get($this->getBasePath('delete-project')); | |
| } | |
| } |