spekkionu/property-access 问题修复 & 功能扩展

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

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

spekkionu/property-access

最新稳定版本:0.4.0

Composer 安装命令:

composer require spekkionu/property-access

包简介

Trait that automatically calls getters and setters for property access.

README 文档

README

Build Status Code Coverage Scrutinizer Code Quality SensioLabsInsight

Trait that automatically calls getters and setters for property access.

use Spekkionu\PropertyAccess\PropertyAccessTrait;

class ExampleClass
{
    use PropertyAccessTrait;

    private $name;

    private $email;

}
$example = new ExampleClass();

$example->name = 'Bob';
$example->email = 'bob@example.com';

echo $example->name; // Bob

$example->fill(array(
    'name' => 'Steve',
    'email' => 'steve@example.com'
));

echo $example->email; // steve@example.com

Getters and Setters will be called

You can even use Value Objects

use Spekkionu\PropertyAccess\PropertyAccessTrait;

class ExampleClass
{
    use PropertyAccessTrait;

    private $name;

    private $email;

    public function setEmail(EmailAddress $email){
        $this->email = $email;
    }

}

// Value Object
class EmailAddress
{
    private $email;

    public function __construct($email)
    {
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            throw new InvalidArgumentException('Not a valid email address.');
        }
        $this->email = $email;
    }

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

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

// Usage
$example = new ExampleClass();
$example->email = new EmailAddress('bob@example.com');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固