From 99ec8e49a2dcca509069324ca6fa039a9323da95 Mon Sep 17 00:00:00 2001 From: Nurlan Mukhanov Date: Mon, 26 Aug 2024 12:47:00 +0600 Subject: [PATCH] 3.1.1 Date and TimeTZ --- composer.json | 2 +- src/DBD/Entity/Columns/DateColumn.php | 53 +++++++++++++++++++++++++ src/DBD/Entity/Columns/TimeColumnTZ.php | 53 +++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 src/DBD/Entity/Columns/DateColumn.php create mode 100644 src/DBD/Entity/Columns/TimeColumnTZ.php diff --git a/composer.json b/composer.json index fcaa8ed..cb4e198 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "falseclock/dbd-php-entity", "type": "library", - "version": "3.1.0", + "version": "3.1.1", "description": "DTO like library to fetch any data in an Object-Oriented manner (ORM)", "keywords": [ "dbd", diff --git a/src/DBD/Entity/Columns/DateColumn.php b/src/DBD/Entity/Columns/DateColumn.php new file mode 100644 index 0000000..60282cf --- /dev/null +++ b/src/DBD/Entity/Columns/DateColumn.php @@ -0,0 +1,53 @@ +] * + * * + * Licensed under the Apache License, Version 2.0 (the "License"); * + * you may not use this file except in compliance with the License. * + * You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, software * + * distributed under the License is distributed on an "AS IS" BASIS, * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * See the License for the specific language governing permissions and * + * limitations under the License. * + * * + ********************************************************************************/ + +declare(strict_types=1); + +namespace DBD\Entity\Columns; + +use Attribute; +use DBD\Entity\Column; +use DBD\Entity\Primitives\TimePrimitives; + +/** + * Class DateColumn + * + * @package DBD\Entity\Columns + */ +#[Attribute(Attribute::TARGET_PROPERTY)] +class DateColumn extends Column +{ + public function __construct( + string $name, + bool $nullable = false, + ?string $defaultValue = null, + ?string $annotation = null + ) + { + parent::__construct([ + Column::NAME => $name, + Column::PRIMITIVE_TYPE => TimePrimitives::Date, + Column::ORIGIN_TYPE => 'date', + Column::NULLABLE => $nullable, + Column::DEFAULT => $defaultValue, + Column::ANNOTATION => $annotation + ]); + } +} diff --git a/src/DBD/Entity/Columns/TimeColumnTZ.php b/src/DBD/Entity/Columns/TimeColumnTZ.php new file mode 100644 index 0000000..d5a1e9c --- /dev/null +++ b/src/DBD/Entity/Columns/TimeColumnTZ.php @@ -0,0 +1,53 @@ +] * + * * + * Licensed under the Apache License, Version 2.0 (the "License"); * + * you may not use this file except in compliance with the License. * + * You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, software * + * distributed under the License is distributed on an "AS IS" BASIS, * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * See the License for the specific language governing permissions and * + * limitations under the License. * + * * + ********************************************************************************/ + +declare(strict_types=1); + +namespace DBD\Entity\Columns; + +use Attribute; +use DBD\Entity\Column; +use DBD\Entity\Primitives\TimePrimitives; + +/** + * Class TimeColumnTZ + * + * @package DBD\Entity\Columns + */ +#[Attribute(Attribute::TARGET_PROPERTY)] +class TimeColumnTZ extends Column +{ + public function __construct( + string $name, + bool $nullable = false, + ?string $defaultValue = null, + ?string $annotation = null + ) + { + parent::__construct([ + Column::NAME => $name, + Column::PRIMITIVE_TYPE => TimePrimitives::TimeOfDay, + Column::ORIGIN_TYPE => 'timetz', + Column::NULLABLE => $nullable, + Column::DEFAULT => $defaultValue, + Column::ANNOTATION => $annotation + ]); + } +}