承接 phpgt/typesafegetter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phpgt/typesafegetter

最新稳定版本:v1.3.2

Composer 安装命令:

composer require phpgt/typesafegetter

包简介

An interface for objects that expose type-safe getter methods.

README 文档

README

Throughout PHP.Gt repositories, wherever an object represents enclosed data, a consistent interface is used to expose the data in a type-safe manner.

Build status Code quality Code coverage Current version PHP.Gt/TypeSafeGetter documentation

The following methods are defined by this interface:

  • get(string $name):mixed - A non-type-safe getter, used for getting keys that are not of an inbuilt type
  • getString(string $name):?string
  • getInt(string $name):?int
  • getFloat(string $name):?float
  • getBool(string $name):?bool
  • getDateTime(string $name):?DateTimeInterface
  • getInstance(string $name, class-string<T> $className):?T

Common areas you will see this interface used:

  • Database rows
  • User input (from the query string or posted form data)
  • Session and cookie storage
  • PHP.Gt's DataObject repository.

NullableTypeSafeGetter trait

A lot of repositories within PHP.Gt that utilise this class were repeating the same getter code, so this trait was introduced to remove the repetition. All getter functions of the interface are implemented, introducing a protected helper function getNullableType which removes the repetition of checking null values before casting them. The getNullableType function also allows a callback to be passed as the type parameter, allowing more complex nullable types to be constructed.

统计信息

  • 总下载量: 15.99k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-16