improve code style

Cette révision appartient à :
Daniel Seifert 2024-12-29 00:42:21 +01:00
Parent 29a764bcfb
révision 59f927af32
Signé par: DanielS
ID de la clé GPG: 6A513E13AEE66170
4 fichiers modifiés avec 42 ajouts et 11 suppressions

Voir le fichier

@ -1,8 +1,10 @@
<?php <?php
/** /**
* For the full copyright and license information, please view the LICENSE * Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
* file that was distributed with this source code. *
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
* *
* https://www.d3data.de * https://www.d3data.de
* *
@ -73,14 +75,14 @@ class Connection
*/ */
public function getClient(): ClientInterface public function getClient(): ClientInterface
{ {
$this->client = $this->client ?? $this->client ??=
new Client([ new Client([
'base_uri' => self::URL, 'base_uri' => self::URL,
'headers' => [ 'headers' => [
'Content-Type' => 'application/json', 'Content-Type' => 'application/json',
'Accept' => 'application/json', 'Accept' => 'application/json',
'User-Agent' => self::USERAGENT.'/'.InstalledVersions::getVersion('d3/klicktipp-php-client') 'User-Agent' => self::USERAGENT.'/'.InstalledVersions::getVersion('d3/klicktipp-php-client'),
] ],
]); ]);
return $this->client; return $this->client;
@ -91,12 +93,12 @@ class Connection
* @param string $uri * @param string $uri
* @param array $options * @param array $options
* @return ResponseInterface * @return ResponseInterface
* @throws BaseException|GuzzleException * @throws BaseException
*/ */
public function request(string $method, string $uri, array $options = []): ResponseInterface public function request(string $method, string $uri, array $options = []): ResponseInterface
{ {
try { try {
$options['query'] = $options['query'] ?? []; $options['query'] ??= [];
$options[RequestOptions::COOKIES] = $this->getCookiesJar(); $options[RequestOptions::COOKIES] = $this->getCookiesJar();
if (! empty($options['body'])) { if (! empty($options['body'])) {
@ -114,6 +116,8 @@ class Connection
$e->getResponse()->getStatusCode(), $e->getResponse()->getStatusCode(),
$e $e
); );
} catch (GuzzleException $e) {
throw new BaseException($e->getMessage(), $e->getCode(), $e);
} }
} }
@ -123,7 +127,6 @@ class Connection
* @param array $options * @param array $options
* @return array * @return array
* @throws BaseException * @throws BaseException
* @throws GuzzleException
*/ */
public function requestAndParse(string $method, string $uri, array $options = []): array public function requestAndParse(string $method, string $uri, array $options = []): array
{ {

Voir le fichier

@ -1,5 +1,18 @@
<?php <?php
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
namespace D3\KlicktippPhpClient\Exceptions; namespace D3\KlicktippPhpClient\Exceptions;
use Exception; use Exception;

Voir le fichier

@ -1,5 +1,18 @@
<?php <?php
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
namespace D3\KlicktippPhpClient\Exceptions; namespace D3\KlicktippPhpClient\Exceptions;
class NoCredentialsException extends BaseException class NoCredentialsException extends BaseException

Voir le fichier

@ -1,8 +1,10 @@
<?php <?php
/** /**
* For the full copyright and license information, please view the LICENSE * Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
* file that was distributed with this source code. *
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
* *
* https://www.d3data.de * https://www.d3data.de
* *
@ -40,7 +42,7 @@ class Klicktipp
string $client_key, string $client_key,
string $secret_key, string $secret_key,
ClientInterface $client = null ClientInterface $client = null
){ ) {
$this->client_key = $client_key; $this->client_key = $client_key;
$this->secret_key = $secret_key; $this->secret_key = $secret_key;