承接 eclipxe/construct-named-parameters 相关项目开发

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

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

eclipxe/construct-named-parameters

Composer 安装命令:

composer require eclipxe/construct-named-parameters

包简介

Helper functions to create objects using an array as named parameters

关键字:

README 文档

README

Source Code Latest Version Software License Build Status Scrutinizer Coverage Status Total Downloads SensioLabsInsight

PHP does not have the option to call a method or instance an object using named parameters. This is a library I use in other projects to simplify the task of create objects based on named parameters.

See PHP RFC: Named Parameters

Instalation

Use composer to install this library composer require eclipxe/construct-named-parameters

Basic use

<?php

class Foo
{
    public function __construct($a, $b, $c, $d) {}
}

$foo = construct_named_parameters(Foo::class, [
    'd' => 123,
    'b' => 'second',
    'a' => 'a argument',
    'c' => false,
    'xtra' => 'baz',
]);

// this will return the result of:
new Foo('a argument', 'second', false, 123);

Why this library exists?

My motivation start in a project that contains a lot of domain objects that need to be instantiated and commonly I had all the information in one single array. This library result very useful in those cases.

It even contains a method that put all parameters and values as lowercase to easily match the constructor requirement. Be aware that in some weird cases a constructor can contain two parameters with the same name but in different case.

How it knows the constructor arguments?

The only way I found is using \Reflection.

The bad is that reflection can be expensive.

The good part is that the function \ConstructNamedParameters\Builder::retrieveArguments has a cache of the name of the class, so, it will only investigate the constructor the first time and the second will use the cached information.

The cache can not be cleaned or forced to reload, and there is no need to do it. A constructor of a class cannot change once it exists, right?

About the public functions:

Public function Actual calls
construct_named_parameters \ConstructNamedParameters\Builder::create
construct_named_parameters_uncase \ConstructNamedParameters\Builder::createIgnoreCase
constructor_arguments \ConstructNamedParameters\Builder::retrieveArguments

Contributing

Contributions are welcome! Please read CONTRIBUTING for details and don't forget to take a look in the TODO and CHANGELOG files.

Copyright and License

The construct-named-parameters library is copyright © Carlos C Soto and licensed for use under the MIT License (MIT). Please see LICENSE for more information.

eclipxe/construct-named-parameters 适用场景与选型建议

eclipxe/construct-named-parameters 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 48 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 06 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「named parameters」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 eclipxe/construct-named-parameters 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 eclipxe/construct-named-parameters 我们能提供哪些服务?
定制开发 / 二次开发

基于 eclipxe/construct-named-parameters 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-06-15