3 * @copyright Copyright (C) 2010-2021, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 use Friendica\Network\HTTPException;
27 * The Entity classes directly inheriting from this abstract class are meant to represent a single business entity.
28 * Their properties may or may not correspond with the database fields of the table we use to represent it.
29 * Each model method must correspond to a business action being performed on this entity.
30 * Only these methods will be allowed to alter the model data.
32 * To persist such a model, the associated Repository must be instantiated and the "save" method must be called
33 * and passed the entity as a parameter.
35 * Ideally, the constructor should only be called in the associated Factory which will instantiate entities depending
36 * on the provided data.
38 * Since these objects aren't meant to be using any dependency, including logging, unit tests can and must be
39 * written for each and all of their methods
41 abstract class BaseEntity extends BaseDataTransferObject
46 * @throws HTTPException\InternalServerErrorException
48 public function __get(string $name)
50 if (!property_exists($this, $name)) {
51 throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' in Entity ' . static::class);