From 5b315f2cf006580fdec71df75a668081f321996a Mon Sep 17 00:00:00 2001 From: aB0t Date: Wed, 21 Jun 2023 03:10:03 +0200 Subject: [PATCH] update 2023-06-21 03:10:00 --- .../README.md | 4 ++-- .../code.php | 20 +++++++++++++++---- .../code.power | 20 +++++++++++++++---- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/584747d1-3a86-453d-b7a3-a2219de8d777/README.md b/src/584747d1-3a86-453d-b7a3-a2219de8d777/README.md index d910e0c..77a2b0a 100644 --- a/src/584747d1-3a86-453d-b7a3-a2219de8d777/README.md +++ b/src/584747d1-3a86-453d-b7a3-a2219de8d777/README.md @@ -15,9 +15,9 @@ abstract Model #Orange { # Table $table + __construct(Table $table) + {abstract} value(mixed $value, string $field, ...) : mixed - + item(object $item, ?string $table = null) : ?object + + item(?object $item, ?string $table = null) : ?object + items(?array $items = null, ?string $table = null) : ?array - + row(array $item, ?string $table = null) : ?array + + row(?array $item, ?string $table = null) : ?array + rows(?array $items = null, ?string $table = null) : ?array + last(?string $table = null) : ?int # getTableFields(string $table, bool $default = false) : ?array diff --git a/src/584747d1-3a86-453d-b7a3-a2219de8d777/code.php b/src/584747d1-3a86-453d-b7a3-a2219de8d777/code.php index 9785bf3..9321eef 100644 --- a/src/584747d1-3a86-453d-b7a3-a2219de8d777/code.php +++ b/src/584747d1-3a86-453d-b7a3-a2219de8d777/code.php @@ -69,14 +69,20 @@ abstract class Model * Model the values of an item * Example: $this->item(Object, 'table_name'); * - * @param object $item The item object + * @param object|null $item The item object * @param string|null $table The table * * @return object|null * @since 3.2.0 */ - public function item(object $item, ?string $table = null): ?object + public function item(?object $item, ?string $table = null): ?object { + // we must have an object + if (empty($item)) + { + return null; + } + // set the table name if (empty($table)) { @@ -172,14 +178,20 @@ abstract class Model * Model the values of an row * Example: $this->item(Array, 'table_name'); * - * @param array $item The item array + * @param array|null $item The item array * @param string|null $table The table * * @return array|null * @since 3.2.0 */ - public function row(array $item, ?string $table = null): ?array + public function row(?array $item, ?string $table = null): ?array { + // we must have an array + if (empty($item)) + { + return null; + } + // set the table name if (empty($table)) { diff --git a/src/584747d1-3a86-453d-b7a3-a2219de8d777/code.power b/src/584747d1-3a86-453d-b7a3-a2219de8d777/code.power index 4cb2eb3..ad41542 100644 --- a/src/584747d1-3a86-453d-b7a3-a2219de8d777/code.power +++ b/src/584747d1-3a86-453d-b7a3-a2219de8d777/code.power @@ -43,14 +43,20 @@ * Model the values of an item * Example: $this->item(Object, 'table_name'); * - * @param object $item The item object + * @param object|null $item The item object * @param string|null $table The table * * @return object|null * @since 3.2.0 */ - public function item(object $item, ?string $table = null): ?object + public function item(?object $item, ?string $table = null): ?object { + // we must have an object + if (empty($item)) + { + return null; + } + // set the table name if (empty($table)) { @@ -146,14 +152,20 @@ * Model the values of an row * Example: $this->item(Array, 'table_name'); * - * @param array $item The item array + * @param array|null $item The item array * @param string|null $table The table * * @return array|null * @since 3.2.0 */ - public function row(array $item, ?string $table = null): ?array + public function row(?array $item, ?string $table = null): ?array { + // we must have an array + if (empty($item)) + { + return null; + } + // set the table name if (empty($table)) {