定制 danielefavi/fluent-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

danielefavi/fluent-api

Composer 安装命令:

composer require danielefavi/fluent-api

包简介

Class designed for fluent API interface: you can invoke the same method statically and non-statically.

README 文档

README

PHP package for fluent API interfaces: you can invoke a method both statically and non-statically.

Installation

composer require danielefavi/fluent-api

Usage

1) Import the FluentApi class in the file you need it.

use DanieleFavi\FluentApi\FluentApi;

2) Extend your class with FluentApi class.

class FluentMath extends FluentApi
{

}

3) Create your methods that can be invoked statically and non-statically.

Declare the functions that can be called statically or non-statically with an underscore _.

In the example below the functions add and subtract can be invoked statically or non-statically.

class FluentMath extends FluentApi
{
    private $result = 0;

    protected function _add($num)
    {
        $this->result += $num;

        return $this;
    }

    protected function _subtract($num)
    {
        $this->result -= $num;

        return $this;
    }

    public function result()
    {
        return $this->result;
    }
}

4) Example of usage

$res1 = FluentMath::add(5)
    ->add(3)
    ->subtract(2)
    ->add(8)
    ->result();

$res2 = FluentMath::subtract(1)
    ->add(10)
    ->result();

// $res1 equals to 14
// $res2 equals to 9

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固