定制 scottaubrey/befriender 二次开发

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

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

scottaubrey/befriender

Composer 安装命令:

composer require scottaubrey/befriender

包简介

A library to enable classes to allow select foreign classes and allow them to affect internal properties

README 文档

README

A library to enable classes to allow select foreign classes and allow them to affect internal properties

Befriender gives a really simple API to allow specified classes access to the private state of other classes. It coes so through the magic methods __get, __set, etc.

Requirements

PHP 7.0+

How to use

use composer to install the library composer require scottaubrey/befriender.

Then add the Befriender trait to the class you want to share state, like so:

#!php
<?php
class Person
{
    use Befriender\Befriender;

    private $name;

    // the rest of the class
}

finally, call ::befriend at an appropriate point (most likely this is the point you construct your class), passing in the class to allow access as a string:

#!php
<?php
class Person
{
    use Befriender\Befriender;

    private $name;

    public function __construct()
    {
        $this->befriend(MyFriend::class);
    }
    // the rest of the class
}

There are full examples in the examples folder.

Disclaimer

I don't use this in production. You probably shouldn't either, and wait for PHP to get better state sharing, or design your classes around it.

If you know what this does though, it's nice not to maintain it yourself.

License

Befriender is licensed under the MIT License

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固