You've already forked dolibarr-api
added JsonSerializable interface
This commit is contained in:
@@ -4,15 +4,16 @@ namespace Magdev\DolibarrApi\Model;
|
|||||||
|
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
|
use JsonSerializable;
|
||||||
|
|
||||||
class StatusModel extends AbstractModel implements ModelInterface
|
class StatusModel extends AbstractModel implements ModelInterface, JsonSerializable
|
||||||
{
|
{
|
||||||
private ?string $dolibarrVersion = null;
|
private ?string $dolibarrVersion = null;
|
||||||
private ?bool $accessLocked = null;
|
private ?bool $accessLocked = null;
|
||||||
private ?string $environment = null;
|
private ?string $environment = null;
|
||||||
private ?DateTimeImmutable $timestampNowUtc = null;
|
private ?DateTimeImmutable $timestampNowUtc = null;
|
||||||
private ?DateTimeZone $timestampPhpTz = null;
|
|
||||||
private ?DateTimeImmutable $dateTz = null;
|
private ?DateTimeImmutable $dateTz = null;
|
||||||
|
private ?DateTimeZone $timestampPhpTz = null;
|
||||||
|
|
||||||
public function __construct(?array $data = null)
|
public function __construct(?array $data = null)
|
||||||
{
|
{
|
||||||
@@ -21,12 +22,20 @@ class StatusModel extends AbstractModel implements ModelInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function jsonSerialize(): mixed
|
||||||
|
{
|
||||||
|
return $this->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
public function fromArray(array $data): static
|
public function fromArray(array $data): static
|
||||||
{
|
{
|
||||||
$this->setDolibarrVersion(dolibarrVersion: $data['dolibarr_version'])
|
$this->setDolibarrVersion(dolibarrVersion: $data['dolibarr_version'])
|
||||||
->setAccessLocked(accessLocked: (bool) $data['access_locked'])
|
->setAccessLocked(accessLocked: (bool) $data['access_locked'])
|
||||||
->setEnvironment(environment: $data['environment'])
|
->setEnvironment(environment: $data['environment'])
|
||||||
->setTimestampNowUtc(timestampNowUtc: new DateTimeImmutable('@'.$data['timestamp_now_utc'], new DateTimeZone('UTC')))
|
->setTimestampNowUtc(timestampNowUtc: new DateTimeImmutable(
|
||||||
|
'@'.$data['timestamp_now_utc'],
|
||||||
|
new DateTimeZone('UTC')
|
||||||
|
))
|
||||||
->setDateTz(dateTz: $data['date_tz'])
|
->setDateTz(dateTz: $data['date_tz'])
|
||||||
->setTimestampPhpTz(timestampPhpTz: $data['timestamp_php_tz'])
|
->setTimestampPhpTz(timestampPhpTz: $data['timestamp_php_tz'])
|
||||||
->setStatusCode(statusCode: $data['code'])
|
->setStatusCode(statusCode: $data['code'])
|
||||||
|
|||||||
Reference in New Issue
Block a user