Skip to content

Commit

Permalink
Draw based on the id or the instance of the poll
Browse files Browse the repository at this point in the history
  • Loading branch information
akiyamaSM committed May 10, 2019
1 parent 6b73bb8 commit 13dd799
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/helpers/PollWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ class PollWriter
* @param Poll $poll
* @return string
*/
public function draw(Poll $poll)
public function draw($poll)
{
if(is_int($poll)){
$poll = Poll::findOrFail($poll);
}

if(!$poll instanceof Poll){
throw new \InvalidArgumentException("The argument must be an integer or an instance of Poll");
}

if ($poll->isComingSoon()) {
return 'To start soon';
}
Expand Down

0 comments on commit 13dd799

Please sign in to comment.