承接 collection-interop/queue 相关项目开发

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

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

collection-interop/queue

Composer 安装命令:

composer require collection-interop/queue

包简介

An interface describing the behaviours of a 'queue' abstract data type (ADT).

README 文档

README

An interface describing the behaviours of a 'queue' abstract data type (ADT).

Installation

The best way to use these interfaces in your project/library, is via Composer:

$ composer require collection-interop/queue

Usage

final class RouteTable implements \Interop\Collection\Queue
{
    private $routes = [];
    private $type = '';
    
    public function enqueue(object $item): void
    {
        if (!$this->type) {
            $this->type = get_class($item);
        }
        
        if (!($item instanceof $this->type)) {
            throw new InvalidArgumentException(
                sprintf('Item must be an instance of %s. Instance of %s was given instead.', $this->type, get_class($item))
            );
        }
        
        $this->routes[] = $item;
    }
    
    public function dequeue(): object
    {
        return array_shift($this->routes);
    }
}

final class Route
{
    public $name;
    public function __construct(string $name) {
        $this->name = $name;
    }
}

final class RouteTwo
{
    public $name = 'two';
}

$routeTable = new RouteTable();
$routeTable->enqueue(new Route('one'));
//$routeTable->enqueue(new RouteTwo());   // uncomment line to verify that only objects of same type can be added
$routeTable->enqueue(new Route('three'));

var_dump($routeTable->dequeue()->name);   // returns 'one'
var_dump($routeTable->dequeue()->name);   // returns 'three'

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固