Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php declare(strict_types=1); |
| 2 | /* |
| 3 | * This file is part of Aplus Framework MVC Library. |
| 4 | * |
| 5 | * (c) Natan Felles <natanfelles@gmail.com> |
| 6 | * |
| 7 | * For the full copyright and license information, please view the LICENSE |
| 8 | * file that was distributed with this source code. |
| 9 | */ |
| 10 | namespace Framework\MVC; |
| 11 | |
| 12 | use stdClass; |
| 13 | |
| 14 | /** |
| 15 | * Interface ModelInterface. |
| 16 | * |
| 17 | * @package mvc |
| 18 | * |
| 19 | * @see https://en.wikipedia.org/wiki/Create,_read,_update_and_delete |
| 20 | */ |
| 21 | interface ModelInterface |
| 22 | { |
| 23 | /** |
| 24 | * Create a new item. |
| 25 | * |
| 26 | * @param array<string,float|int|string|null>|Entity|stdClass $data |
| 27 | * |
| 28 | * @return false|int|string The created item id on success or false if it could not |
| 29 | * be created |
| 30 | */ |
| 31 | public function create(array | Entity | stdClass $data) : false | int | string; |
| 32 | |
| 33 | /** |
| 34 | * Read an item based on id. |
| 35 | * |
| 36 | * @since 3.6 |
| 37 | * |
| 38 | * @param int|string $id |
| 39 | * |
| 40 | * @return array<string,float|int|string|null>|Entity|stdClass|null The |
| 41 | * item as array, Entity or stdClass or null if the item was not found |
| 42 | */ |
| 43 | public function read(int | string $id) : array | Entity | stdClass | null; |
| 44 | |
| 45 | /** |
| 46 | * Update based on id and return the number of updated items. |
| 47 | * |
| 48 | * @param int|string $id |
| 49 | * @param array<string,float|int|string|null>|Entity|stdClass $data |
| 50 | * |
| 51 | * @return false|int|string The number of updated items or false if it could |
| 52 | * not be updated |
| 53 | */ |
| 54 | public function update(int | string $id, array | Entity | stdClass $data) : false | int | string; |
| 55 | |
| 56 | /** |
| 57 | * Delete based on id. |
| 58 | * |
| 59 | * @param int|string $id |
| 60 | * |
| 61 | * @return false|int|string The number of deleted items or false if it could not be |
| 62 | * deleted |
| 63 | */ |
| 64 | public function delete(int | string $id) : false | int | string; |
| 65 | } |