fix(continuous-integration): correction php-cs-fixer
All checks were successful
Cadoles/nineskeletor/pipeline/pr-master This commit looks good

This commit is contained in:
2022-09-23 16:14:15 +02:00
parent 5f3cc51f5c
commit b78f54b76c
70 changed files with 5943 additions and 5549 deletions

View File

@ -3,46 +3,52 @@
namespace App\Service;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
class ApiService
{
private $params;
public function __construct(ParameterBagInterface $params)
{
$this->params = $params;
}
public function setbody(Array $array)
public function setbody(array $array)
{
return \Unirest\Request\Body::json($array);
}
public function run($method,$url,$query,$header=null,$content="json") {
public function run($method, $url, $query, $header = null, $content = 'json')
{
// Entete
$headerini=null;
switch($content) {
case "json":
$headerini = null;
switch ($content) {
case 'json':
$headerini = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
if($query) $query = \Unirest\Request\Body::json($query);
break;
if ($query) {
$query = \Unirest\Request\Body::json($query);
}
break;
case "form":
case 'form':
$headerini = [
'Accept' => 'application/json',
'Content-Type' => 'application/x-www-form-urlencoded',
];
if($query) $query = \Unirest\Request\Body::form($query);
break;
];
if ($query) {
$query = \Unirest\Request\Body::form($query);
}
break;
}
if($header) $header=array_merge($headerini,$header);
else $header=$headerini;
if ($header) {
$header = array_merge($headerini, $header);
} else {
$header = $headerini;
}
// Paramétrage unirest
\Unirest\Request::verifyPeer(false);
@ -50,60 +56,56 @@ class ApiService
\Unirest\Request::timeout(5);
// Déclaration du proxy
$proxyUse = $this->params->get("proxyUse");
if($proxyUse) {
$proxyHost = $this->params->get("proxyHost");
$proxyPort = $this->params->get("proxyPort");
$proxyUse = $this->params->get('proxyUse');
if ($proxyUse) {
$proxyHost = $this->params->get('proxyHost');
$proxyPort = $this->params->get('proxyPort');
\Unirest\Request::proxy($proxyHost, $proxyPort, CURLPROXY_HTTP, true);
}
$response = false;
switch($method) {
case "POST":
try{
$response = \Unirest\Request::post($url,$header,$query);
}
catch (\Exception $e) {
switch ($method) {
case 'POST':
try {
$response = \Unirest\Request::post($url, $header, $query);
} catch (\Exception $e) {
return false;
}
break;
case "GET":
try{
$response = @\Unirest\Request::get($url,$header,$query);
}
catch (\Exception $e) {
case 'GET':
try {
$response = @\Unirest\Request::get($url, $header, $query);
} catch (\Exception $e) {
return false;
}
break;
case "PUT":
try{
$response = \Unirest\Request::put($url,$header,$query);
}
catch (\Exception $e) {
case 'PUT':
try {
$response = \Unirest\Request::put($url, $header, $query);
} catch (\Exception $e) {
return false;
}
break;
break;
case "DELETE":
try{
$response = \Unirest\Request::delete($url,$header,$query);
}
catch (\Exception $e) {
case 'DELETE':
try {
$response = \Unirest\Request::delete($url, $header, $query);
} catch (\Exception $e) {
return false;
}
break;
case "PATCH":
try{
$response = \Unirest\Request::patch($url,$header,$query);
}
catch (\Exception $e) {
break;
case 'PATCH':
try {
$response = \Unirest\Request::patch($url, $header, $query);
} catch (\Exception $e) {
return false;
}
break;
break;
}
return $response;
}
}