承接 devmakerlab/entities 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

devmakerlab/entities

Composer 安装命令:

composer require devmakerlab/entities

包简介

Work with entities from your services or repositories.

README 文档

README

Run tests Code Coverage Latest Stable Version

This package provide a way to implements entities. Useful for your services or repositories.

Usage

Create your entity in dedicated class :

use DevMakerLab\Entity;

class Human extends Entity
{
    public string $name;
    public int $age;
}

Then instanciate a new entity like that :

$human = new Human([
    'name' => 'Bob',
    'age' => 42,
]);

echo $human->name; // Bob
echo $human->age; // 42

Create your entity list like this :

use DevMakerLab\EntityList;

class People extends EntityList
{
    public function getYoungest(): Human
    {       
        $entities = $this->entities;

        uasort($entities, function ($a, $b) {
            if ($a->age === $b->age) {
                return 0;
            }
    
            return ($a > $b) ? -1 : 1;
        });

        return array_pop($entities);
    }
}

Then instanciate a list like that :

$bob = new Human(['name' => 'Bob', 'age' => 45]);
$junior = new Human(['name' => 'Junior', 'age' => 21]);
$jane = new Human(['name' => 'Jane', 'age' => 31]);

$people = new People([$bob, $junior]);
$people[] = $jane;

echo $people[0]->name; // Bob
echo $people[1]->name; // Junior
echo $people->getYoungest()->name; // Junior

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固