f2/getset
Composer 安装命令:
composer require f2/getset
包简介
A trait `F2\GetSet` that implements getters and setters with public, protected and private visibility and type checking.
README 文档
README
Simple library that enables creating getters and setters with PHP in a consistent manner. Supports visibility and type hinting.
Simple getter and setter
<?php
class MyClass {
use F2\GetSet;
private $secret_value = "Initial value";
/**
* Any method that starts with "get_" is automatically a getter
*
* public, protected and private visibility is accepted and enforced.
* Type checking is enforced by PHP automatically.
*/
public function get_value(): string {
return $this->secret_value;
}
/**
* Any method that starts with "set_" is automatically a getter
*
* public, protected and private visibility is accepted and enforced.
* Type checking is enforced by PHP automatically.
*/
public function set_value(string $value): void {
$this->secret_value = $value;
}
}
$instance = new MyClass();
$instance->value .= ' and some more';
// Log: The property 'value' was read
// Log: The property 'value' was set to 'Initial value and some more'
## No dependencies
This library has no dependencies (except a development dependency f2/asserty)
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-12