Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #82: class is considered final #83

Merged
merged 3 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added

### Changed
- [refactor CTClient:](https://github.com/5pm-HDH/churchtools-api/pull/83) transform inheritance from GuzzleClient to composition-relation

### Fixed

Expand Down
12 changes: 9 additions & 3 deletions src/CTClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@
/**
* @psalm-suppress InvalidExtendClass
*/
class CTClient extends Client
class CTClient
{
private Client $guzzleClient;
private static ?CTClient $client = null;

public function __construct(array $config = [])
{
$this->guzzleClient = new Client($config);
}

protected static function mergeOptions(array $options): array
{
return array_merge_recursive($options, CTConfig::getRequestConfig());
Expand All @@ -28,7 +34,7 @@ public function get($uri, array $options = []): ResponseInterface
{
try {
CTLog::getLog()->debug('CTClient: GET-Request URI:' . $uri, ["options" => $options, "mergedOptions" => self::mergeOptions($options)]);
return $this->handleResponse(parent::get($uri, self::mergeOptions($options)));
return $this->handleResponse($this->guzzleClient->get($uri, self::mergeOptions($options)));
} catch (Exception $exception) {
return $this->handleException($exception);
}
Expand All @@ -38,7 +44,7 @@ public function post($uri, array $options = []): ResponseInterface
{
try {
CTLog::getLog()->debug('CTClient: POST-Request URI:' . $uri, ["options" => $options, "mergedOptions" => self::mergeOptions($options)]);
return $this->handleResponse(parent::post($uri, self::mergeOptions($options)));
return $this->handleResponse($this->guzzleClient->post($uri, self::mergeOptions($options)));
} catch (Exception $exception) {
return $this->handleException($exception);
}
Expand Down
11 changes: 11 additions & 0 deletions src/Models/GroupInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ protected function fillArrayType(string $key, array $data): void
}
}

protected function fillNonArrayType(string $key, $value): void
{
switch ($key){
case "weekday":
$this->weekday = [$value];
break;
default:
$this->{$key} = $value;
}
}

/**
* @return string|null
*/
Expand Down