WIP: Extend and improve profile editing

This commit is contained in:
Björn Fromme committed 2023-10-01 16:39:32 +02:00
1 parent 6595fbec8a
commit d776d37cd5
27 files changed
+553 -375

No files matched your search

@@ -0,0 +1,41 @@
<?php
namespace App\BusProNet\Model;
class NotificationResponse
{
private ?int $code;
private ?string $message;
public function __construct(int $code = null, string $message = null)
{
$this->code = $code;
$this->message = $message;
}
public function getCode(): ?int
{
return $this->code;
}
public function getMessage(): ?string
{
return $this->message;
}
public function isSuccessful(): bool
{
// Successful responses don't carry codes and messages
if (null === $this->getCode() && null === $this->getMessage()) {
return true;
}
// These weird and contradictory looking assertions are required because
// of the stupid API implementation that doesn't distinguish between error
// and success responses.
$responseIsError = 100 <= $this->getCode() || $this->getMessage() === 'Daten konnten nicht gesendet werden.';
$responseIsSuccess = 650 === $this->getCode() && false === stripos($this->getMessage(), 'fehler');
return false === $responseIsError && true === $responseIsSuccess;
}
}