parfumix/php-function-arguments 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

parfumix/php-function-arguments

Composer 安装命令:

composer require parfumix/php-function-arguments

包简介

README 文档

README

Argument helper is an class helper which can help wich help you to reduce the arguments of php function and easy convert it to class and can extracted and validated ..

    // From ..
    public function example($arg1, $arg2, $arg3, $arg4 = null, $arg5 = array());
    // To ..
    public function example(Argumentable $args);

Instalation

You can use the composer package manager to install. Either run:

$ php composer.phar require parfumix/php-function-arguments "dev-master"

or add:

"parfumix/php-function-arguments": "dev-master"

to your composer.json file

Usage

You can easy create an instance of arugments by using args helper functions

$args = args();

// or if you want to pass some values and rules
$args = args($values = array(), $rules = array());

// or you can use ::create static functions
$args = Argument::create($values = array(), $rules = array());

Argument implements php interfaces like "Argumentable, ArrayAccess, Iterator, IteratorAggregate, Countable" so you can easy iterate by arguments or access elements as array or count your arguments

$args = args($values = array(
    'key' => 'value'
));

// to access an arguments you can use
$args['key']
// or
$args->get('key')

// counting arguments
count($args)

Validation

You can easy validate arguments using validation function or call object as function (using __invoke)

$args = args();
$args->set('key', 'value');

// You can validate your args before
if( ! $args->validate(function($failedFields) {
    // you can do whetever with failed fields ..
}) )

class Example {
    public function needParams(Argumentable $args) {
        // Or you can validate here .
        if( ! $args->validate(function($failedFields) {
            // you can do whetever with failed fields ..
        }) )
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固