wip: initial commit
This commit is contained in:
1 parent
ae964198e9
commit
d4c4e69d09
91 files changed
+32685
-144
No files matched your search
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
class Notification
|
||||
{
|
||||
public function __construct(int $code, string $message)
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
public ?int $code;
|
||||
public ?string $message;
|
||||
|
||||
public function isSuccessful(): bool
|
||||
{
|
||||
// Successful responses don't carry codes and messages
|
||||
if (null === $this->code && null === $this->message) {
|
||||
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->code || $this->message === 'Daten konnten nicht gesendet werden.';
|
||||
$responseIsSuccess = 650 === $this->code && false === stripos($this->message, 'fehler');
|
||||
|
||||
return false === $responseIsError && true === $responseIsSuccess;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user