lots of improvements
This commit is contained in:
45
shared/lib/Resource/Delta/Delta.php
Normal file
45
shared/lib/Resource/Delta/Delta.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Resource\Delta;
|
||||
|
||||
use KTXF\Json\JsonSerializable;
|
||||
|
||||
class Delta implements JsonSerializable {
|
||||
|
||||
public function __construct(
|
||||
public ?DeltaCollection $additions = null,
|
||||
public ?DeltaCollection $modifications = null,
|
||||
public ?DeltaCollection $deletions = null,
|
||||
public ?string $signature = null,
|
||||
) {
|
||||
if ($this->additions === null) {
|
||||
$this->additions = new DeltaCollection;
|
||||
}
|
||||
if ($this->modifications === null) {
|
||||
$this->modifications = new DeltaCollection;
|
||||
}
|
||||
if ($this->deletions === null) {
|
||||
$this->deletions = new DeltaCollection;
|
||||
}
|
||||
if ($this->signature === null) {
|
||||
$this->signature = '';
|
||||
}
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'signature' => $this->signature,
|
||||
'additions' => $this->additions,
|
||||
'modifications' => $this->modifications,
|
||||
'deletions' => $this->deletions,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
18
shared/lib/Resource/Delta/DeltaCollection.php
Normal file
18
shared/lib/Resource/Delta/DeltaCollection.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Resource\Delta;
|
||||
|
||||
use KTXF\Json\JsonSerializableCollection;
|
||||
|
||||
class DeltaCollection extends JsonSerializableCollection {
|
||||
public function __construct($data = []) {
|
||||
parent::__construct($data, self::TYPE_STRING);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user