承接 sugatasei/bredala-data 相关项目开发

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

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

sugatasei/bredala-data

Composer 安装命令:

composer require sugatasei/bredala-data

包简介

PHP modeling and data manipulation class

README 文档

README

PHP modeling and data manipulation tools.

Data

Data is designed to be extends to help create entities, models, ...

Data implements JsonSerializable for all public non static properties.

MicroCache

Micro-caching tools. Store data only during the script execution.

use Bredala\Data\MicroCache;

if (null === ($foo = MicroCache::get('foo'))) {
    $foo = 'bar';
    MicroCache::set('foo', $foo);
}

Special use : the value can be null

use Bredala\Data\MicroCache;

if (null === ($nullable = MicroCache::get('nullable')) && !MicroCache::has('nullable')) {
    $nullable = null;
    MicroCache::set('nullable', $nullable);
}

ArrayHelper

Extract part of array

Creates an array from another array keeping only certain keys.

use Bredala\Data\ArrayHelper;

$arry = ArrayHelper::extract([
    'id' => 1,
    'name' => 'John Doe',
    'city' => 'London'
], ['id', 'name']);

Extract part of array

Creates an array from another array keeping only certain keys.

use Bredala\Data\ArrayHelper;

$ary = ArrayHelper::extract([
    'id' => 1,
    'name' => 'John Doe',
    'city' => 'London'
], ['id', 'name']);

Rename keys

Rename a keys from an array

use Bredala\Data\ArrayHelper;

$ary = ArrayHelper::renameKeys([
    'id' => 1,
    'name' => 'John Doe',
    'city' => 'London'
], [
    'id' => 'user_id'
]);

Add prefix to keys

use Bredala\Data\ArrayHelper;

$ary = ArrayHelper::addPrefix([
    'id' => 1,
    'name' => 'John Doe',
    'city' => 'London'
], 'user_');

Remove prefix to keys

use Bredala\Data\ArrayHelper;

$ary = ArrayHelper::removePrefix([
    'user_id' => 1,
    'user_name' => 'John Doe',
    'user_city' => 'London'
], 'user_');

Encoder/Decoder

Encoders helps to transform PHP data to storage type. Decoders helps to tranform data from storage to PHP type.

Encoders & Decoders are usefull inside adapters.

  • BooleanEncoder Encode/Decode 0-1 integer to/from PHP boolean
  • DataEncoder Encode/Decode array to/from Data object
  • DataListEncoder : Encode/Decode array of array to/from array of Data objects
  • DateTimeEncoder : Encode/Decode date with string representation to/from PHP DateTime objects
  • JsonEncoder
  • TimestampEncoder : Encode/Decode date with string representation to/from PHP Unix Timestamp

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-06