hectororm/data-types

v1.0.0-beta2 2022-02-18 23:26 UTC

This package is auto-updated.

Last update: 2023-01-19 01:16:49 UTC


README

Latest Version Software license Build Status Quality Grade Total Downloads

Hector Data Types is the module to manage types of Hector ORM. Can be used independently of ORM.

Installation

Composer

You can install Hector Data Types with Composer, it's the recommended installation.

$ composer require hectororm/data-types

Dependencies

  • PHP ^8.0
  • Extensions dependencies:
    • ext-pdo

Usage

Each type converter implement interface:

use Hector\DataTypes\ExpectedType;

interface TypeInterface
{
    /**
     * From schema function.
     *
     * @return string|null
     */
    public function fromSchemaFunction(): ?string;

    /**
     * From schema to entity.
     *
     * @param mixed $value
     * @param ExpectedType|null $expected
     *
     * @return mixed
     */
    public function fromSchema(mixed $value, ?ExpectedType $expected = null): mixed;

    /**
     * To schema function.
     *
     * @return string|null
     */
    public function toSchemaFunction(): ?string;

    /**
     * From entity to schema.
     *
     * @param mixed $value
     * @param ExpectedType|null $expected
     *
     * @return mixed
     */
    public function toSchema(mixed $value, ?ExpectedType $expected = null): mixed;

    /**
     * Get binding type.
     * Must return a PDO::PARAM_* value.
     *
     * @return int|null
     */
    public function getBindingType(): ?int;
}

Attempted excepted type is a representation of PHP type of property.