定制 naffiq/php-randomorg-draws 二次开发

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

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

naffiq/php-randomorg-draws

Composer 安装命令:

composer require naffiq/php-randomorg-draws

包简介

PHP Random.org draws

README 文档

README

Build Status Test Coverage Code Climate

This library helps you with connecting your app to Random.org's Third-Party Draws service.

Installation

Preferable way to install this package is through composer:

$ composer require naffiq/php-randomorg-draws

Usage

You have to register random.org account and provide login/password to \naffiq\randomorg\DrawService constructor. Then you can create draws via \naffiq\randomorg\DrawService::newDraw() method, which will spawn an object of \naffiq\randomprg\Draw.

<?php

$service = new \naffiq\randomorg\DrawService('random.org_login', 'random.org_password');
$draw = $service->newDraw(
    'Title',                                    // Name of the draw
    1,                                          // ID of created draw, which will be passed to random.org
    ['user_1@email.com', 'user_2@email.com'],   // You can provide any unique identifiers of your participants
    1,                                          // Winners count 
    'test'                                      // Use 'private' or 'public' in production
    );

$draw->pushEntry('user_3@email.com'); // Adds new entry

To start draw run \naffiq\randomorg\DrawService::holdDraw() method with created $draw. In result you will get instance of \naffiq\randomorg\DrawResponse class.

<?php

/**
 * @var $service \naffiq\randomorg\DrawService
 * @var $draw \naffiq\randomorg\Draw
 */
$response = $service->holdDraw($draw);

var_dump($response->getWinners()); // Will output all winners of created draw

Handling API errors

Any error, that was generated by Random.org API is thrown as an instance of \naffiq\randomorg\DrawException. It passes error code and message as well as additional data, which is accessible via \naffiq\randomorg\DrawException::getData() method.

Contributing and testing

Any contribution is highly welcomed. If you want to run tests provide RANDOMORG_LOGIN and RANDOMORG_PASSWORD environment variables. They can be automatically initialized them from .env file. Just specify them as follows:

RANDOMORG_LOGIN=your_random_org_login
RANDOMORG_PASSWORD=your_random_org_password

And run

$ phpunit

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-07-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固