mirror of
https://github.com/opdavies/gmail-filter-builder.git
synced 2025-01-22 12:07:32 +00:00
Add a filter() helper method
Add a namespaced `filter()` method that can be imported via `use function` and use it as an alternative for `new Filter` or `Filter::create()`. This provides a cleaner, easier to read syntax - particularly if you have a lot of filters in the same file.
This commit is contained in:
parent
31cfaf8f6f
commit
330d6f9393
|
@ -23,6 +23,7 @@
|
|||
"symfony/var-dumper": "^3.4"
|
||||
},
|
||||
"autoload": {
|
||||
"files": ["src/Helpers.php"],
|
||||
"psr-4": {
|
||||
"Opdavies\\GmailFilterBuilder\\": "src/"
|
||||
}
|
||||
|
|
12
src/Helpers.php
Normal file
12
src/Helpers.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Opdavies\GmailFilterBuilder;
|
||||
|
||||
use Opdavies\GmailFilterBuilder\Model\Filter;
|
||||
|
||||
function filter(): Filter
|
||||
{
|
||||
return new Filter();
|
||||
}
|
17
tests/Unit/HelpersTest.php
Normal file
17
tests/Unit/HelpersTest.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use Opdavies\GmailFilterBuilder\Model\Filter as FilterClass;
|
||||
use function Opdavies\GmailFilterBuilder\filter;
|
||||
|
||||
final class HelpersTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function it_returns_a_filter_object(): void
|
||||
{
|
||||
$this->assertEquals(new FilterClass(), filter());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue