sissokho/laravel-dev-joke
最新稳定版本:v2.0.0
Composer 安装命令:
composer require sissokho/laravel-dev-joke
包简介
This package offer a simple way to fetch a random dev joke from the DevJoke API
README 文档
README
This package offer a simple way to fetch a random dev joke from this DevJoke API.
Prerequisites
This package requires:
- PHP 8.1 or higher
- Laravel 9.0 or higher
If you are on the PHP version 8.0 just use an older version of this package.
Installation
You can install the package via composer:
composer require sissokho/laravel-dev-joke
Usage
This package can be used by resolving the Sissokho\LaravelDevJoke\DevJoke class from the container or by injecting it into a method:
use Sissokho\LaravelDevJoke\DevJoke; public function joke(DevJoke $devJoke) { $joke = $devJoke->random(); $joke->question; // retrieve the question $joke->punchline; // retrieve the punchline $joke->toArray(); // ['question' => 'lorem', 'punchline' => 'ipsum'] }
The randomJoke method will return a Sissokho\LaravelDevJoke\DataTransferObjects\Joke object, which includes the question and the punchline of the joke;
You can also use the Facade:
use Sissokho\LaravelDevJoke\Facades\DevJoke; $joke = DevJoke::random();
Artisan
An artisan command is provided for you to display a random joke:
php artisan devjoke
The joke is displayed like this:
Testing
You can run PHPUnit tests, PHPStan/Larastan static analysis and inspect the code for style errors without changing the files (with Laravel Pint):
composer test
However, you can run these tests separately.
- Static analysis:
composer test:types
- PHPUnit tests:
composer test:unit
- Code inspection:
composer test:style
To fix code style issues, run the following command:
composer stylefix
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
Huge thanks to @askudhay for providing this API.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-26
