Last active
August 29, 2015 14:18
-
-
Save lukevers/42beb9f00af6e713fa35 to your computer and use it in GitHub Desktop.
App\Tips\Tip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Tips; | |
class NewUser extends Tip { | |
/** | |
* An array of tips. | |
* | |
* @var array | |
*/ | |
protected $tips = [ | |
'Use 1Password to generate your password', | |
'Make sure to save your account details', | |
]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Tips; | |
use Illuminate\Support\Collection; | |
class Tip { | |
/** | |
* The chosen tip. | |
* | |
* @var string | |
*/ | |
protected $tip; | |
/** | |
* An array of tips. | |
* | |
* @var array | |
*/ | |
protected $tips = [ | |
'Write your own class that extends Tip' | |
]; | |
/** | |
* Create a new Tip instance. | |
* | |
* @param array $tips | |
* @return void | |
*/ | |
public function __construct($tips = null) | |
{ | |
if (!is_null($tips)) | |
{ | |
$this->tips = $tips; | |
} | |
$this->handle(); | |
} | |
/** | |
* Handle the tip. | |
* | |
* @return void | |
*/ | |
public function handle() | |
{ | |
$this->tip = Collection::make($this->tips)->random(); | |
} | |
/** | |
* Print out a tip | |
* | |
* @return string | |
*/ | |
public function __toString() | |
{ | |
return $this->tip; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment