Skip to content

Commit

Permalink
feat: add static method make() for quick access/run
Browse files Browse the repository at this point in the history
  • Loading branch information
Dovyski committed Jun 22, 2021
1 parent 7ca69ba commit 7dbafc9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ composer require ccuffs/poll-from-text

Instantiate the class `CCUFFS\Text\PollFromText` then call `parse()`:

>*Tip:* use `CCUFFS\Text\PollFromText::make()` if you don't want to instantiate an object.
```php
$poller = new CCUFFS\Text\PollFromText();
$questions = $poller->parse('Favorite color?')
Expand Down
4 changes: 4 additions & 0 deletions src/PollFromText.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
*/
class PollFromText
{
public static function make($text, array $config = []) {
return (new PollFromText())->parse($text, $config);
}

protected function split($text)
{
return preg_split('/\R+/', $text, 0, PREG_SPLIT_NO_EMPTY);
Expand Down
11 changes: 11 additions & 0 deletions tests/Unit/StaticCallTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use CCUFFS\Text\PollFromText;

test('one simple question', function() {
$poll = PollFromText::make('Favorite color?');
$this->assertEquals([[
'text' => 'Favorite color?',
'type' => 'input'
]], $poll);
});

0 comments on commit 7dbafc9

Please sign in to comment.