定制 drewlabs/php-value 二次开发

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

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

drewlabs/php-value

最新稳定版本:v0.3.21

Composer 安装命令:

composer require drewlabs/php-value

包简介

PHP object builder and serialization library

README 文档

README

# PHP Value

The library provides utility objects for PHP application and projects.

## Usage

The library offer two interface for creating an object.

Your can use OOP implementation you can extends the abstract [Drewlabs\PHPValue\Value] class:

- Object oriented implementation

```php
use Drewlabs\PHPValue\ObjectAdapter;

class ValueStub extends ObjectAdapter
{
    protected $__PROPERTIES__ = [
        'name',
        'address',
    ];
}

// Creating instance
$value = new ValueStub([
    'name' => 'Azandrew',
    'address' => '288 Avenue Pia, Lome'
]);
```

Or using the [Drewlabs\PHPValue\Functions\CreateValue] function.

- Functional interface

```php
// Imports
use function Drewlabs\PHPValue\Functions\CreateAdapter;

$value =  CreateAdapter([
    // dynamic properties
    'name',
    'address'
]);
```

Using both ways, you create an instance of [\Drewlabs\PHPValue\Value] class.

- Creating a copy of the object

```php
// Imports
use function Drewlabs\PHPValue\Functions\CreateAdapter;
$value =  CreateAdapter([
    // dynamic properties
    'name',
    'address'
]);

// This tries to create a deep copy of the object
$value1 = $value->copy([
    'name' => 'Sidoine Azandrew'
]);
```

- Getting property of the object

The value object is Array accessible meaning we can user [] operator to acces object properties. It also overrides magic [__get] method for properties accesibility and offers a [getAttribute()] method that query for a property on the object

```php
// Imports
use function Drewlabs\PHPValue\Functions\CreateAdapter;
$value =  CreateAdapter([
    // dynamic properties
    'name',
    'address'
]);

$result = $value['name']; 
// Same as
$result = $value->name;
// Same as
$result = $value->getAttribute('name');
```

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固