定制 germania-kg/shipping 二次开发

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

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

germania-kg/shipping

Composer 安装命令:

composer require germania-kg/shipping

包简介

README 文档

README

Classes and interfaces for dealing with shipment items

Packagist PHP version Tests

Installation

$ composer require germania-kg/shipping

Requirements

This package requires germania-kg/tracking package.

Usage

ShipmentItemInterface

The ShipmentItemInterface extends Germania\Shipping\DeliveryNoteNumberProviderInterface and Germania\Tracking\TrackingInfoAwareInterface and \JsonSerializable . So these methods are provided:

  • getDeliveryNoteNumber
  • getTrackingInfo
  • setTrackingInfo
  • jsonSerialize

ShipmentItem

The ShipmentItem class implements ShipmentItemInterface and additionally provides setter methods setTrackingInfo and setDeliveryNoteNumber:

<?php
use Germania\Shipping\ShipmentItem;
use Germania\Tracking\TrackingInfo;

// Prepare components
$tracking_info = new TrackingInfo;
$tracking_info->setTrackingID("foo");
$tracking_info->setTrackingLink("https://track.test.com/?id=foo");

// Use setters
$item = new ShipmentItem;
$item->setDeliveryNoteNumber( "123456" );
$item->setTrackingInfo( $tracking_info );

// Use getters
echo $item->getDeliveryNoteNumber();              // "123456"
echo $item->getTrackingInfo()->getTrackingLink(); // "https://track.test.com/?id=foo"
echo $item->getTrackingInfo()->getTrackingID();   // "foo"

ShipmentItemFactory

The fromArray method accepts both array and ArrayAccess with these keys required:

  • delivery_note_number
  • tracking_id
  • tracking_link

Anything else passed will trigger a InvalidArgumentException or UnexpectedValueException respectively.

<?php
use Germania\Shipping\ShipmentItemFactory;  
use Germania\Shipping\ShipmentItemInterface;  

$item_factory = new ShipmentItemFactory;
$item = $item_factory->fromArray([
 	'delivery_note_number' => '123456',
  'tracking_id' => 'foo',
  'tracking_link' => 'https://track.test.com/?id=foo'
]);

echo ($item instanceOf ShipmentItemInterface)
? "OK" : "huh?";

ShipmentItemBundle

Bundles multiple shipment items and lets you add a textual description. It additionally implements \IteratorAggregate, \Countable, and \JsonSerializable:

<?php
use Germania\Shipping\ShipmentItemBundle; 

// Prepare
$item1 = new ShipmentItem; #...
$item2 = new ShipmentItem; #...

$items = array(
	$item1,
  $item2
);

// Setup bundle
$description = "Optional: textual desription";
$bundle = new ShipmentItemBundle( $items, $description);
$bundle = new ShipmentItemBundle( $items);

// Add item
$bundle->push( new ShipmentItem );

// Play
$array = $bundle->getDeliveryNoteNumbers();
echo $bundle->getDescription();
echo count( $bundle ); // int 3

foreach ($bundle as $item) {
	echo $item->getDeliveryNoteNumber();  
}

echo json_encode( $bundle );

Development

$ git clone https://github.com/GermaniaKG/Shipping.git shipping
$ cd shipping
$ composer install

# Run PhpUnit
$ composer test

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固