| 1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace cx_newsletter;
- abstract class database_item
- implements database_item_interface {
- public function __construct(?int $id = null) {
- $this->id = $id;
- }
- public function has_id() : bool {
- return $this->id !== null;
- }
- public function get_id() : int {
- if (!$this->has_id()) {
- $exception = "\n\n";
- $exception .= 'Database item which ID trying to be loaded, has ';
- $exception .= 'no ID. That mean it could not exists, in the ';
- $exception .= 'database, because only items which not exists in ';
- $exception .= 'the database has not own ID.';
- $exception .= "\n\n";
- throw new \exception($exception);
- }
-
- return $this->id;
- }
- private ?int $id;
- }
|