codeat3/icndb

0.1.4 2021-03-12 13:34 UTC

This package is auto-updated.

Last update: 2024-09-12 20:40:57 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

此PHP包是Cyrus David的jcldavid/ICNDb的分支。

安装

您可以通过composer安装此包

composer require codeat3/icndb

用法

$config = array(
	'firstName' => 'Cyrus',
	'lastName' => 'David'
);

// Pass an optional parameter to change the firstName and lastName
// Default is Chuck Norris
$chuck = new Swapnilsarwe\ICNDbClient($config);

// Get the total Chuck Norris jokes stored in ICNDb
$total = $chuck->count()->get();

// Get all categories
$categories = $chuck->categories()->get();

// Get a specific joke by it's ID
$specific = $chuck->specific(18)->get();

//Get a random joke
$random = $chuck->random()->get();

// Get multiple random jokes
$random2 = $chuck->random(3)->get();

// use exclude() to get jokes not belong to that category
$exclude = $chuck->random()->exclude('nerdy')->get();

// you can also supply an array
$exclude2 = $chuck->random()->exclude(array('nerdy', 'explicit'))->get();

// or chain them
$exclude3 = $chuck->random(2)->exclude('explicit')->exclude('nerdy')->get();

// use limitTo() to get jokes only from that category
// you may supply an array or chain them like exclude()
$limit = $chuck->random()->limitTo('nerdy')->get();

异常

APIUnavailableException - API不可达或不可用

ChainNotAllowedException - 当这些方法链在一起时 random(), specific($id), categories(), count()

测试

composer test

变更日志

请参阅CHANGELOG以获取更多信息。

贡献

请参阅CONTRIBUTING以获取详细信息。

安全

如果您发现任何与安全相关的问题,请通过swapnilsarwe@gmail.com发送电子邮件,而不是使用问题跟踪器。

致谢

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。

PHP包模板

此包是使用PHP包模板生成的。