Completed
Push — master ( c954bb...642bd1 )
by Zoltán
10:14
created

GuzzleClient::request()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 12
rs 9.4286
cc 2
eloc 6
nc 2
nop 2
1
<?php namespace Phabricator\Client\Guzzle;
2
3
use BuildR\Foundation\Exception\RuntimeException;
4
use GuzzleHttp\Client;
5
use Phabricator\Client\ClientInterface;
6
7
/**
8
 * Simple Guzzle based client
9
 *
10
 * Phabricator PHP API
11
 *
12
 * @author Zoltán Borsos <[email protected]>
13
 * @package Phabricator
14
 * @subpackage Client\Guzzle
15
 *
16
 * @copyright    Copyright 2016, Zoltán Borsos.
17
 * @license      https://github.com/Zolli/Phabricator-PHP-API/blob/master/LICENSE.md
18
 * @link         https://github.com/Zolli/Phabricator-PHP-API
19
 */
20
class GuzzleClient implements ClientInterface {
21
22
    /**
23
     * {@inheritDoc}
24
     *
25
     * @codeCoverageIgnore
26
     */
27
    public function request($url, $requestData) {
28
        if(!class_exists('GuzzleHttp\Client')) {
29
            throw new RuntimeException('The guzzle client is not installed. Please install uzzlehttp/guzzle');
30
        }
31
32
        $client = new Client();
33
34
        //We do not care exceptions, this will handled by the user
35
        $response = $client->request('POST', $url, ['form_params' => $requestData]);
36
37
        return $response->getBody()->getContents();
38
    }
39
40
41
}
42