This repository has been archived on 2024-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
epubreader/lib/Db/ReaderEntity.php

39 lines
860 B
PHP
Raw Normal View History

2020-04-21 20:37:42 +00:00
<?php
/**
* @author Frank de Lange
* @copyright 2015 Frank de Lange
*
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCA\Epubreader\Db;
2020-04-21 20:37:42 +00:00
use OCP\AppFramework\Db\Entity;
2023-06-16 19:20:03 +00:00
abstract class ReaderEntity extends Entity {
2020-04-21 20:37:42 +00:00
2023-06-16 19:20:03 +00:00
protected int $lastModified; // modification timestamp
2023-06-16 14:58:23 +00:00
/* returns decoded json if input is json, otherwise returns input */
2023-06-16 19:20:03 +00:00
public static function conditional_json_decode(string $el): mixed {
2023-06-16 14:58:23 +00:00
$result = json_decode($el);
if (json_last_error() === JSON_ERROR_NONE) {
return $result;
} else {
return $el;
}
}
2023-06-16 19:20:03 +00:00
public function getLastModified(): int {
2023-06-16 14:58:23 +00:00
return $this->lastModified;
}
2020-04-21 20:37:42 +00:00
2023-06-16 19:20:03 +00:00
public function setLastModified(int $lastModified): void {
2023-06-16 14:58:23 +00:00
$this->lastModified = $lastModified;
}
2023-06-16 19:20:03 +00:00
abstract public function toService(): array;
2023-06-16 14:58:23 +00:00
}