germania-kg/retailers
Composer 安装命令:
composer require germania-kg/retailers
包简介
Work with Retailers: Interfaces, Traits, FilterIterator
README 文档
README
Installation with Composer
$ composer require germania-kg/retailers
Interfaces
RetailerNumberProviderInterface
public function getRetailerNumber()
RetailerNumberAwareInterface
extends RetailerNumberProviderInterface public function setRetailerNumber( $id )
Traits
RetailerNumberProviderTrait
Objects using this trait will provide a retailer_number attribute and a getRetailerNumber getter method, as outlined here:
public $retailer_number; public function getRetailerNumber()
RetailerNumberAwareTrait
Objects using this trait will provide anything that RetailerNumberProviderInterface provides, and additionally a setter method setRetailerNumber which accepts anything; if RetailerNumberProviderInterface given here, getRetailerNumber method will be called to obtain the ID to use. Roughly outlined:
use RetailerNumberProviderTrait; public function setRetailerNumber( $id )
Examples
<?php use Germania\Retailers\RetailerNumberProviderInterface; use Germania\Retailers\RetailerNumberProviderTrait; class Retailer implements RetailerNumberProviderInterface { use RetailerNumberProviderTrait; public function __construct( $retailer_number ) { $this->retailer_number = $retailer_number; } } $retailer = new Retailer( 99 ); echo $retailer->getRetailerNumber(); // 99
<?php use Germania\Retailers\RetailerNumberAwareInterface; use Germania\Retailers\RetailerNumberAwareTrait; class MyOrder implements RetailerNumberAwareInterface { use RetailerNumberAwareTrait; } $order = new MyOrder; $order->setRetailerNumber( 34 ); echo $order->getRetailerNumber(); // 34
RetailerFilterIterator
The RetailerFilterIterator class accepts any Iterator collection and a retailer ID (or ID array) or RetailerNumberProviderInterface instance to filter for. Collection items not being an instance of RetailerNumberProviderInterface are always ignored.
Iterator:
- instances of RetailerNumberProviderInterface
Filter values:
- Integer or string ID
- Array of integer or string IDs
- One instance of RetailerNumberProviderInterface – also see issue #1
Example:
<?php use Germania\Retailers\RetailerFilterIterator; // Prepare some RetailerNumberProviderInterface instances: $order1 = new MyOrder; $order1->setRetailerNumber( 1 ); $order2 = new MyOrder; $order2->setRetailerNumber( 20 ); $order3 = new MyOrder; $order4->setRetailerNumber( 999 ); $orders = [ $order1, $order2, $order3 ]; // --------------------------------------- // Filter by ID or ID array: // --------------------------------------- // should be '1' $filter = new RetailerFilterIterator( new \ArrayIterator( $orders ) , 20); echo iterator_count($filter); // should be '2' $filter = new RetailerFilterIterator( new \ArrayIterator( $orders ), array(20, 999)); echo iterator_count($filter); // --------------------------------------- // Filter by RetailerNumberProviderInterface: // --------------------------------------- $retailer = new Retailer( 1 ); $filter = new RetailerFilterIterator( new \ArrayIterator( $orders ), $retailer); // should be '1' echo iterator_count($filter);
Roadmap
Version 2.1:
- Use Scalar type declarations; requires PHP 7.0+
Issues
- The RetailerFilterIterator should also accept an array of RetailerNumberProviderInterface instances as filter value. See issue #1.
Development
$ git clone https://github.com/GermaniaKG/Retailers.git
$ cd Retailers
$ composer install
Unit tests
Either copy phpunit.xml.dist to phpunit.xml and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:
$ composer test # or $ vendor/bin/phpunit
germania-kg/retailers 适用场景与选型建议
germania-kg/retailers 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 542 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 07 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 germania-kg/retailers 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 germania-kg/retailers 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 542
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-05