letsdrink/ouzo-goodies
Composer 安装命令:
composer require letsdrink/ouzo-goodies
包简介
Utility classes, test assertions and mocking framework extracted from Ouzo framework.
README 文档
README
What is it
Utility classes, test assertions and mocking framework extracted from Ouzo framework. PHP 8.4 or later is required.
How to use it
Couple of examples.
$result = FluentArray::from($users) ->map(Functions::extractField('name')) ->filter(Functions::notEmpty()) ->unique() ->toArray();
$result = FluentIterator::fromArray([1, 2, 3]) ->cycle() ->limit(10) ->reindex() ->toArray(); // [1, 2, 3, 1, 2, 3, 1, 2, 3, 1]
$product = new Product(['name' => 'super phone']); $function = FluentFunctions::extractField('name') ->removePrefix('super') ->prepend(' extra') ->append('! ') ->surroundWith("***"); $result = Functions::call($function, $product); //=> '*** extra phone! ***'
$phones = Arrays::filter($products, FluentFunctions::extractField('type')->equals('PHONE'));
$cities = Arrays::map($users, Functions::extract()->getAddress('home')->city);
$string = Clock::now() ->plusYears(1) ->plusMonths(2) ->minusDays(3) ->format();
$product1 = new Product(['name' => 'b']); $product2 = new Product(['name' => 'c']); $product3 = new Product(['name' => 'a']); $result = Arrays::sort([$product1, $product2, $product3], Comparator::compareBy('name'));
$animals = ['cat', 'dog', 'pig']; Assert::thatArray($animals)->hasSize(3)->contains('cat');
Fluent assertions for strings:
Assert::thatString("Frodo") ->startsWith("Fro") ->endsWith("do") ->contains("rod") ->doesNotContain("fro") ->hasSize(5);
$mock = Mock::create(); Mock::when($mock)->someMethod('arg')->thenReturn('123'); $result = $mock->someMethod('arg'); $this->assertEquals('123', $result); Mock::verify($mock)->method('arg');
$foo = new Foo(); CatchException::when($foo)->method(); CatchException::assertThat()->isInstanceOf("FooException");
This is just a taste of Ouzo. Look at the documentation for more goodies.
Where to get it
Download from github or simply add composer dependency:
composer require letsdrink/ouzo-goodies
Documentation
Tutorials:
Utilities:
- Arrays - Helper functions for arrays.
- FluentArray - Interface for manipulating arrays in a chained fashion.
- Iterators - Helper functions for iterators.
- FluentIterator- Interface for manipulating iterators in a chained fashion.
- Strings - Helper functions for strings.
- Objects- Helper functions that can operate on any PHP object.
- Functions - Static utility methods returning closures that can be used with Arrays and FluentArray, or other PHP functions.
- FluentFunctions - Fluent utility for function composition.
- Cache - General-purpose cache.
- Path - Helper functions for path operations.
- Clock - DateTime replacement.
- Comparators - Sorting.
Tests:
- Assertions for arrays
- Assertions for exceptions
- Assertions for strings
- Mocking
- Testing time-dependent code
Check out full docs at http://ouzo.readthedocs.org
PhpStorm plugins:
- Ouzo framework plugin
- DynamicReturnTypePlugin - for Mock and CatchException. You have to copy dynamicReturnTypeMeta.json to your project root.
For ideas, questions, discussions write to ouzo-framework@googlegroups.com.
Support for older PHP versions
Ouzo Goodies 4.x requires PHP 8.4 or later. For older PHP versions:
- PHP 8.2 — use Ouzo 3.x branch
- PHP 8.0 — use Ouzo 2.x branch
- PHP 5.6 / 7.x — use Ouzo 1.x branch
letsdrink/ouzo-goodies 适用场景与选型建议
letsdrink/ouzo-goodies 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 654.9k 次下载、GitHub Stars 达 129, 最近一次更新时间为 2014 年 12 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「TDD」 「test」 「mock」 「utils」 「utilities」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 letsdrink/ouzo-goodies 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 letsdrink/ouzo-goodies 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 letsdrink/ouzo-goodies 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Helper that decorates any SUS with a phpspec lazy object wrapper
Provides access to magento2 object manager from behat and allows to change magento config settings temporarly
Testing Suite For Lumen like Laravel does.
Specification-oriented BDD helpers for PHPUnit
Lumen fork of orchestra/testbench-core - Testing Helper for Lumen Development
KissTest is command-line free, fast, simple and beautiful unit test framework.
统计信息
- 总下载量: 654.9k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 133
- 点击次数: 27
- 依赖项目数: 10
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-16